<%@page import="com.sq.partner.manager.util.StrUtil"%>
<%@page import="java.sql.Struct"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<% String path=request.getContextPath(); String basePath=request.getScheme()+ "://" + request.getServerName() + ":" + request.getServerPort() + path+ "/"; %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head>
<base href="<%=basePath%>">
<title>投保方案复制新增</title>
<%@ include file="/WEB-INF/jsp/common/common.jsp" %>
<style type="text/css">
.input_text{width:180px;}
.select_1{width:180px;}
#agentType3Table{
	 margin: auto;
}
#agentType4Table{
	 margin: auto;
}
#agentType3Table td{
	border: 1px solid #bbcddb;
	height:15px; 
	line-height:15px;
}
#agentType4Table td{
	border: 1px solid #bbcddb;
	height:15px; 
	line-height:15px;
}
</style>
<script src="js/jquery.validate.js" type="text/javascript" ></script>
<script src="js/jquery.divbox.js" type="text/javascript"></script>
<script src="js/json2.js" type="text/javascript"></script>
<script type="text/javascript">
var salemap=new Map();
var channelFlag="";
var epolicyType="";
var econfirmType="";
//销售人员信息保存
var emailMap=new Map();
function  saveSale(){
	var salemap1=new Map();
	var arr1 = new Array(); 
	for (var i = 1; i <= 5; i++) {
		var flag=0;
		var j=0;
		var o=new Object();
		var seqNo=$('#flag'+i).val();
		o.seqNo=seqNo;
		//销售人员类别
		var saletype=$('#saletype'+i).val();
		var saleName=$('#saletype'+i).find("option:selected").text()
		if(saletype!='0'){
			o.saleType=saletype;
			o.saleName=saleName;
			j=j+1;
			flag=flag+1;
		}
		//费用比例
		var saleRate=$('#saleRate'+i).val();
		if($.trim(saleRate)!=''){
			o.agentFee=saleRate;
			j=j+1;
			flag=flag+1;
		}
		//执业证号
		var saleCallNo=$('#saleCallNo'+i).val();
		if($.trim(saleCallNo)!=''){
			o.practiceNo=saleCallNo;
		}
		//人员类别
		var saleMentype=$('#saleMentype'+i).val();
		var saleMenName= $('#saleMentype'+i).find("option:selected").text();
		if(saleMentype!='0'){
			o.personType=saleMentype;
			o.personTypeName=saleMenName;
			flag=flag+1;
			j=j+1;
		}
		//销售人员
		var saleMen=$('#saleMen'+i).val();
		if($.trim(saleMen)!=''){
			o.salePerson=saleMen;
			flag=flag+1;
		}
		//业务员
		var empNo=$('#empNo'+i).val();
		if($.trim(empNo)!=''){
			o.empNo=empNo;
			flag=flag+1;
			j=j+1;
		}
		//代理人编号
		var agentNo=$('#agentNo'+i).val();
		if($.trim(agentNo)!=''){
			o.agentNo=agentNo;
			flag=flag+1;
		}
		if(j>=1&&j!=4){
			$.message("error","序号为"+i+"的数据存在必填项未填写，请填写");
			return;			
		}
		if($.trim(saleRate)!=''){
			if(i!=1){
				var o1=salemap1.get(i-1);
				if(o1==null||o1==undefined||o1==false){
					$.message("error","序号为"+i+"的上一个序号未填写不能跳号");
					return;		
				}
			}
			salemap1.put(i,o);
		}
		if($.trim(saleRate)!=''){
			arr1.push(o);
		}
	}
	var rate=0;
	var isEmp=false;
	for (var i = 1; i <= 5; i++) {
		if(salemap1.get(i)){
			//比例校验 所有人员类别是业务员的比例之和是1，其他类别只能是0.
			if(salemap1.get(i).personType=='1'){
				if(salemap1.get(i).agentFee==''||salemap1.get(i).agentFee==undefined){
				}else{
					rate=parseFloat(rate)+parseFloat(salemap1.get(i).agentFee)
				}
				isEmp=true;
			}else{
				if(salemap1.get(i).agentFee!='0'){
					$.message("error","所有人员类别是业务员的比例之和是1，其他类别只能是0");
					salemap1.clear();
					return;	
				}
			}
		}
	}
	if(parseFloat(rate)!=1&&isEmp){
		$.message("error","所有人员类别是业务员的比例之和是1，其他类别只能是0");
		salemap1.clear();
		return;
	}
	var insplanno = $('#hidepno').val();
	var flag=true;
	$.openLoading();
	if(false){
		 var arr=JSON.stringify(arr1);
		$.ajax({
			url : "<%=path%>/noCarInsure/addTradPlanSale",
			type : 'POST',
			async : true,
			data:{
				planCode:insplanno,
				planType:'2',
				saleArry:arr
			},
			dataType:'json',
			success:function(result){
				if(result.result=='success'){
					$.closeLoading();
					salemap.clear();
					salemap=salemap1;
					saleTable();
					closeNocarAgentTypeDiv('sale_div');
					$.message("success", "添加成功");
				}else{
					$.message("error", "添加失败");
				}
			}
		});
	}else{
		$.closeLoading();
		salemap.clear();
		salemap=salemap1;
		saleTable();
		closeNocarAgentTypeDiv('sale_div');
		$.message("success", "添加成功");
		
	}
}
function clearNoNum1(event,obj){ 
	obj.value = obj.value.replace(/[^\d.]/g,"");  //清除“数字”和“.”以外的字符   
	  obj.value = obj.value.replace(/\.{2,}/g,"."); //只保留第一个. 清除多余的   
	  obj.value = obj.value.replace(".","$#$").replace(/\./g,"").replace("$#$",".");  
	  obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d\d).*$/,'$1$2.$3');//只能输入两个小数   
	  if(obj.value.indexOf(".")< 0 && obj.value !=""){//以上已经过滤，此处控制的是如果没有小数点，首位不能为类似于 01、02的金额  
	   obj.value= parseFloat(obj.value);  
	  }  	
} 
//当“是否发送短信”的值为“是”时，短信模板配置可输入
function changeIsCancelMessage(){
	var isMessage = $.trim($('#isCancelMessage').val());
	if(isMessage =='Y'){
		$('#cancelReceiverDiv').show();
		$('#cancelTemplateTr').show();
		//$('#cancelTemplate').css("background-color","white");
		$('#cancelTemplate').attr("disabled",true).css("background-color","rgb(204, 204, 204)");
		$('#cancelTemplateDiv').show();
	}else{
		$('#cancelReceiverDiv').hide();
		$('#cancelTemplateTr').hide();
		$('#cancelTemplate').val('');
		$('#cancelTemplateDiv').hide();
		$('#isCancelTemplate').val('');
	}
}

//展示选中的注销短信模板
function changeIsCacelTemplate(){
	var value = $('#isCancelTemplate').val();
	if(value ==null || "" == value || "0" == value){
		$('#cancelTemplate').val("");
		return false;
	}
	 $.ajax({
		 	url : "<%=path%>/noCarInsure/loadTemplate",
			type : 'POST',
			async : true,
			dataType:'json',
			data:{smsTemplateCode:value},
			success : function(obj) {
				var smsTemplate = obj;
				$('#cancelTemplate').val(obj.smsTemplateText);
			}
	});
}
//下载方式改变方式
function downloadWayChange(flag1){
	var flag=$('#DownloadWay').val();
	if(flag=='1'){
		$('#fileTypeSpan').show()
	}else{
		$('#fileTypeSpan').hide()
	}
	var isEpolicyMali =$('#isEpolicyMali').val();
	if(isEpolicyMali=='1'){
	  	setEmailTemplate(flag1);
	}
}
//销售人员table
function saleTable(){
	$('#saleShowDiv').html('');
	var ht='';
	for (var i = 1; i <=5; i++) {
		var o=salemap.get(i);
		if(o.personTypeName==undefined){
			o.personTypeName='';
		}
		if(o.empNo==undefined){
			o.empNo='';
		}
		if(o.salePerson==undefined){
			o.salePerson='';
		}
		if(o.agentNo==undefined){
			o.agentNo='';
		}
		if(o.practiceNo==undefined){
			o.practiceNo="";
		}
		if(o){
			ht+='<tr>'+
			'<td style="width:100px;text-align: center;">'+o.seqNo+'</td>'+
			'<td style="width:100px;text-align: center;">'+o.saleName+'</td>'+
			'<td style="width:100px;text-align: center;">'+o.agentFee+'</td>'+
			'<td style="width:100px;text-align: center;">'+o.practiceNo+'</td>'+
			'<td style="width:100px;text-align: center;">'+o.personTypeName+'</td>'+
			'<td style="width:100px;text-align: center;">'+o.empNo+'</td>'+
			'<td style="width:100px;text-align: center;">'+o.salePerson+'</td>'+
			'<td style="width:100px;text-align: center;">'+o.agentNo+'</td>'
		}
	}
	$('#saleShowDiv').html(ht);
}
var rolemap=new Map();
//销售人员信息
function opensaleDiv(){
	if(!rolemap.get("saleMenTypes")){
		$.ajax({
			url : "<%=path%>/noCarInsure/loadDic",
			type : 'POST',
			async : true,
			data:{},
			dataType:'json',
			success:function(data){
				rolemap.put("saleMenTypes", data.saleMenTypes);
				rolemap.put("saleTypes", data.saleTypes);
				createSale();
			}
		});
	}else {
		createSale();
	}
}
function getSale(i){
	var roles=rolemap.get("saleMenTypes");
	var hr='<select id="saleMentype'+i+'" class="select_1 valid" style=" width: 130px">'
			+'<option value="0">请选择</option>'
		for (var j = 0; j < roles.length; j++) {
			hr+='<option value="'+roles[j].code+'">'+roles[j].codeName+'</option>'
		}
		hr+='</select>';
	return hr;
}
function getSale1(i){
	var roles=rolemap.get("saleTypes");
	var hr='<select id="saletype'+i+'" class="select_1 valid" style=" width: 130px">'
			+'<option value="0">请选择</option>'
		for (var j = 0; j < roles.length; j++) {
			hr+='<option value="'+roles[j].code+'">'+roles[j].codeName+'</option>'
		}
		hr+='</select>';
	return hr;
}
//是否回执
function chooseReceiptType(){
	var value = $('#isReceipt').val();
	var receiptType = $('#receiptType').val();
	if('Y' == value){
		$('#isOrNotDisplayReceiptTypeDiv').show();
		$('#receiptType').val('01');
	}else if('N' == value){
		$('#isOrNotDisplayReceiptTypeDiv').hide();
	}
}
function createSale(){
	var salecontent=''
		for (var i = 1; i <= 5; i++) {
			salecontent+='<tr>'+
			'<td>'+i+'<input type="hidden" id="flag'+i+'" value="'+i+'"/></td>'+
			'<td>'+
				getSale1(i)+
			'</td>'+
			'<td><input type="text" onkeyup="clearNoNum(event,this)"  id="saleRate'+i+'" style=" width: 130px"/></td>'+							
			'<td><input type="text" id="saleCallNo'+i+'"  class="input_text" style=" width: 130px"/></td>'+								
			'<td>'+
				getSale(i)+
				'</select>'+
			'</td>'+
			'<td><input type="text" id="saleMen'+i+'"  class="input_text" style=" width: 130px"/></td>'+								
			'<td><input type="text" id="empNo'+i+'"  class="input_text" style=" width: 130px"/></td>'+							
			'<td><input type="text" id="agentNo'+i+'"  class="input_text" style=" width: 130px"/></td>'+								
		'</tr>'
		}
		$('#salecontent').html('');
		$('#salecontent').html(salecontent);
		$('#sale_div').OpenDiv()
		//赋值
		for (var i = 1; i <=5; i++) {
		var o=salemap.get(i);
		if(o){
			 $('#flag'+i).val(o.seqNo);
			 $('#saletype'+i).val(o.saleType);
			 $('#saleRate'+i).val(o.agentFee);
			 $('#saleCallNo'+i).val(o.practiceNo);
			 $('#saleMentype'+i).val(o.personType);
			 $('#saleMen'+i).val(o.salePerson);
			 $('#empNo'+i).val(o.empNo);
			 $('#agentNo'+i).val(o.agentNo)
		}
	}
}
//自定义map功能
function Map(){
  this.elements = new Array();
   //获取MAP元素个数
   this.size = function() {
       return this.elements.length;
   };
   //判断MAP是否为空
   this.isEmpty = function() {
       return (this.elements.length < 1);
   };
   //删除MAP所有元素
   this.clear = function() {
       this.elements = new Array();
   };
   //向MAP中增加元素（key, value)
   this.put = function(_key, _value) {
       if(this.containsKey(_key)){
        this.remove(_key);
        this.elements.push( {
           key : _key,
           value : _value
        });
       }else{
        this.elements.push( {
           key : _key,
           value : _value
        });
       }  
   };
   //删除指定KEY的元素，成功返回True，失败返回False
   this.remove = function(_key) {
       var bln = false;
       try {
           for (var i = 0; i < this.elements.length; i++) {
               if (this.elements[i].key == _key) {
                   this.elements.splice(i, 1);
                   return true;
               }
           }
       } catch (e) {
           bln = false;
       }
       return bln;
   };
   //获取指定KEY的元素值VALUE，失败返回NULL
   this.get = function(_key) {
       try {
           for (var i = 0; i < this.elements.length; i++) {
               if (this.elements[i].key == _key) {
                   return this.elements[i].value;
               }
           }
       } catch (e) {
           return false;
       }
       return false;
   };
   //判断MAP中是否含有指定KEY的元素
   this.containsKey = function(_key) {
       var bln = false;
       try {
           for (var i = 0; i < this.elements.length; i++) {
               if (this.elements[i].key == _key) {
                   bln = true;
               }
           }
       } catch (e) {
           bln = false;
       }
       return bln;
   };
  //获取map的所有values
  this.values = function() {
       var arr = new Array();
       for (var i = 0; i < this.elements.length; i++) {
           arr.push(this.elements[i].value);
       }
       return arr;
   };
  //获取map的所有keys
  this.keys= function() {
       var arr = new Array();
       for (var i = 0; i < this.elements.length; i++) {
           arr.push(this.elements[i].key);
       }
       return arr;
   };
   //获取数组
   this.getArray= function(){
   	var arr = new Array();
   	for (var i = 0; i < this.elements.length; i++) {
           arr.push({
	            key : this.elements[i].key,
	            value : this.elements[i].value
	         });
       }
       return arr;
   };
}
//-------------页面开始----------
var poolType = 0;
var prodAppType='';
var prodType='${prodType}';
var agentTypeList = [];
var map = new Map();
var mapBak = new Map();
var oldAgentType = '';//复制来的方案类型
var oldPartnerNo='';//复制来的合作伙伴代码
//------------------------------------------ 初始化本页面 开始----------------------------------------------
<%
String pno = "";
if(null != request.getAttribute("planCode")){
	pno = request.getAttribute("planCode").toString();
	System.out.print("================================================"+(StrUtil.isNotEmpty(pno)));
}
if(StrUtil.isNotEmpty(pno)){
%>
	$(document).ready(function(){
		
		var insplanno = $('#hidepno').val();
		init(insplanno);
		loadPageDropListInfo();
		var sedVal=$("#newBsnsType option:selected").text();
		if(''==$('#agentFeeConfig').val()){
			if(sedVal.indexOf("直销") != -1){
				$("#agentNo").val("");
				$("#protocolNo").val("");
				$("#agentNo").attr("disabled",true);
				$("#protocolNo").attr("disabled",true);
				$("#agentNo").css({"background-color": "#ccc"});
				$("#protocolNo").css({"background-color": "#ccc"});
			}else{
				$("#agentNo").attr("disabled",false);
				$("#protocolNo").attr("disabled",false);
				$("#agentNo").css({"background-color": ""});
				$("#protocolNo").css({"background-color": ""});
			} 	
		}
	})
<%
} else {
%>

$(document).ready(function(){
    loadPageDropListInfo();
    })
<% } %>
function loadPageDropListInfo(){
	//归属渠道
	$("#channelCodeQD").change(function(){
		var parentCode = $("#channelCodeQD").val();
		subDropDownList("channel_type",parentCode,"channelType");
		subDropDownList("new_business_source","","newBsnsType");
	});
	//渠道类型
	$("#channelType").change(function(){
		var parentCode = $("#channelType").val();
		subDropDownList("new_business_source",parentCode,"newBsnsType");
		if(parentCode==''){
			$("#bsnsType").val('');
		}
	});
	//新业务来源
	$("#newBsnsType").change(function(){
		var parentCode = $("#channelType").val();
		var newBsnsCode = $("#newBsnsType").val();
		chooseBsnsType(parentCode,newBsnsCode);
	});
	//旧业务来源
	$("#bsnsType").change(function(){
		var newBsnsCode = $("#newBsnsType").val();
		var bsnsTypeCode = $("#bsnsType").val();
		//原业务来源为19002-代理或19003-经纪，则代理人代码和代理协议号必填，其他非必填
		$("#agentNoButtonHidden").empty();
		if(bsnsTypeCode!="19002"&&bsnsTypeCode!="19003"){
 			$("#agentNo ~ span").remove(".red");

			$("#agentNo").val("");
			$('#agentNo').attr("disabled",true);
			$("#agentNo").css({"background-color": "#ccc"});
			$("#protocolNo").val("");
			$('#protocolNo').attr("disabled",true);
			$("#protocolNo").css({"background-color": "#ccc"});
			$("#protocolNo ~ span").remove(".red");
		}else{
			$("#agentNo").attr("disabled",false);
			$("#agentNo").css({"background-color": ""});
			$("#protocolNo").attr("disabled",false);
			$("#protocolNo").css({"background-color": ""});
			if($("#protocolNo ~ span").length==0){
				$("#protocolNo").parent().append("<span class='red'>*</span>");
			}
			$("#agentNoButtonHidden").html("<span class='red' style='margin-left: -5px'>*</span>&nbsp; ");
		}
	});
}
/**特约配置方式*/
function specialConfigTypeChange(){
	var specialConfigType=$('#specialConfigType').val();
	if(specialConfigType=="1"){
		$('#specialArran').val('');
		$('#specialArran').attr("disabled",true);
		$("#specialArran").css({"background-color": "#ccc"});
	}else{
		$("#specialArran").attr("disabled",false);
		$("#specialArran").css({"background-color": ""});
	}
}
//是否电子发票
//是否电子发票
function epolicyInvoiceChange(){
	var isEpolicyInvoice=$("#isEpolicyInvoice").val();
	if("1"==isEpolicyInvoice){
		$(".CinvockLink").show();
		$("#einvoiceInfo").show();
		isInsurEinvoiceChange();
	}else{
		$(".CinvockLink").hide();
		$("#einvoiceInfo").hide();
	}
	var isEpolicyMali =$('#isEpolicyMali').val();
	if(isEpolicyMali=='1'){
	  	setEmailTemplate();
	}
}
function isInsurEinvoiceChange(){
	var isInsuranceEinvoice=$("#isInsuranceEinvoice").val();
	/* var payEinvoice=$("#payEinvoice").val(); */
	if(isInsuranceEinvoice=='Y'){
		$("#payEinvoice").val('1');
		$('#payEinvoice').attr("disabled",true);
		$('#payEinvoice').css("background-color","#ccc");
	}else{
		$('#payEinvoice').attr("disabled",false);
		$('#payEinvoice').css("background-color","");
	}
}
//下拉框处理
function subDropDownList(codeType,element1,element2){
	$.ajax({
		url : "<%=path%>/noCarInsure/loadSubDropList",
		type : 'POST',
		async : false,
		data:{codeType:codeType,parentCode:element1},
		dataType:'json',
		success:function(appList){
				if($.validate(appList))  return;
				var appSelect = document.getElementById(element2);
				appSelect.options.length = 0;
				if (appList != null) {
					for (var i = 0; i < appList.length; i++) {
						var option = new Option();
						option.text = appList[i].codeName;
						option.value = appList[i].code;
						appSelect.add(option);
					}
				}
       	}
	});
}
//是否回执
function chooseIsedrno(){
	var value = $('#isedrno').val();
	var edrnoType = $('#edrnoType').val();
	if('Y' == value){
		$('#isOrNotDisplayEdrnoTypeDiv').show();
	}else if('N' == value){
		$('#isOrNotDisplayEdrnoTypeDiv').hide();
	}
}
//选择旧业务来源
function chooseBsnsType(parentCode,newBsnsCode){
	$.ajax({
		url : "<%=path%>/noCarInsure/chooseBsnsType",
		type : 'POST',
		async : false,
		data:{parentCode:parentCode,newBsnsCode:newBsnsCode},
		dataType:'json',
		success:function(data){
				if($.validate(data))  return;
				if (data != null) {
					$("#bsnsType").val(data.otherCode);
					//原业务来源为19002-代理或19003-经纪，则代理人代码和代理协议号必填，其他非必填
					if(data.otherCode=="19002"||data.otherCode=="19003"){
						if($("#agentNo ~ span").length==0){
							$("#agentNo").parent().append("<span class='red'>*</span>");
						}
						if($("#protocolNo ~ span").length==0){
							$("#protocolNo").parent().append("<span class='red'>*</span>");
						}
					}else{
						$("#agentNo ~ span").remove(".red");
						$("#protocolNo ~ span").remove(".red");
					}
				}
       	}
	});
}
function init(insplanno){
	$.ajax({
		url : "noCarInsure/loadInsuPlanInfo",
		type : 'POST',
		async : false,
		data:{planCode:insplanno},
		dataType:'json',
		success:function(data){
			if(data.message==undefined){
 				$('#planName').val(data.PLANNAME);
				$('#prodCode').val(data.PRODCODE);
				$('#prodName').val(data.PRODNAME);
				econfirmType=data.ECONFIRMTYPE;
				epolicyType=data.EPOLICYTYPE;
				$('#businessPerformanceRate').val(data.BUSPERRATE);
				$('#marketPreserveRate').val(data.MARKPERRATE);
				$('#partnerCode').val(data.PARTNERCODE);
				oldPartnerNo =data.PARTNERCODE;//复制来的合作伙伴代码
				$('#channelCodeQD').val(data.CHANNELCODE);
				$('#channelType').val(data.CHANNELTYPE);
				$('#newBsnsType').val(data.NEWBSNSTYPE);
				$('#isThirdPlan').val(data.thirdPlan);
 				$('#bsnsType').val(data.BSNSTYPE);
				$('#isEConfirm').val(data.ISECONFIRM);
				$('#isPushedSalesInfo').val(data.isPushedSalesInfo);
 				if("19002"!=data.BSNSTYPE&&"19003"!=data.BSNSTYPE){
					$("#agentNo ~ span").remove(".red");
					$("#protocolNo ~ span").remove(".red");
				}
 				channelFlag=data.channelFlag;
 				channelChannel(channelFlag);
 				//是否回执动态显示
				$('#isReceipt').val(data.ISRECEIPT);
				if(data.ISRECEIPT=='Y'){
					$('#isOrNotDisplayReceiptTypeDiv').show();
					$('#receiptType').val(data.RECEIPTTYPE);
				}
				$('#deptCode').val(data.DEPTCODE);
				$('#deptCode').val(data.DEPTCODE);
				$('#commRate').val(data.COMMRATE);
				$("#agentType").val(data.AGENTTYPE);
				if('6'==data.AGENTTYPE || '5'==data.AGENTTYPE){
					isDisable("agentFeeConfig", false);
				}else{
					isDisable("agentFeeConfig", true);
				}
				//是否批单
				$('#isedrno').val(data.ISEDRNO);
				if(data.ISEDRNO=='Y'){
					$('#isOrNotDisplayEdrnoTypeDiv').show();
					$('#edrnoType').val(data.EDRNOTYPE);
				}
				//1、合作伙伴代理3、个人代理4、总对总代理
				if("1"==data.AGENTTYPE){
					oldAgentType ='1';
					$('#agentNo').val(data.AGENTNO);
					$('#serviceCode').val(data.SERVICECODE);
					$('#empNo').val(data.EMPNO);
					$('#teamCode').val(data.TEAMCODE);
					$('#teamName').val(data.TEAMNAME);
					$('#protocolNo').val(data.PROTOCOLNO);
					$("tr[id^=qudaoandlaiyuan0]").css('display','');
					$("tr[id^=agentType1]").css('display','');
					$("tr[id^=agentType3]").css('display','none');
					$("tr[id^=agentType4]").css('display','none');
					$("#deptCode101").empty();
					$("#deptCode102").empty();
					$("#deptCode101").append("出单机构：");
					$("#deptCode102").append("<input id='deptCode'  type='text' readonly='readonly' style=' background-color: #ccc;' class='input_text'><span class='red'>*</span>&nbsp;<input type='button'  class='input_button_2' id='searchDeptBtn' value='请选择' onClick='openDeptDiv(1,this)' />");
					$('#deptCode').val(data.DEPTCODE);
				}else if("3"==data.AGENTTYPE){
					oldAgentType ='3';
					$("#cardApplicant_div").css('display','none');
					queryNocarConfProxyInfoEdit3(1);
					mapBak.clear();//清空备份map
					for(var o in data.map){  
			        	var obj = new Object();
			        	obj.id = data.map[o].id;
			        	obj.cardapplicant = data.map[o].cardapplicant;
			        	obj.value = data.map[o].value=="null"?"":data.map[o].value;
			        	map.put(obj.id,obj);
			        	mapBak.put(obj.id,obj);
			      	}
					$("#agentType").val(data.AGENTTYPE);
					$("tr[id^=qudaoandlaiyuan0]").css('display','none');
					$("tr[id^=agentType1]").css('display','none');
					$("tr[id^=agentType3]").css('display','');
					$("tr[id^=agentType4]").css('display','none');
					$("#deptCode101").empty();
					$("#deptCode102").empty();
					$("#deptCode102").append("<input type='hidden' id='deptCode' value='' />");
				}else if("4"==data.AGENTTYPE){
					oldAgentType ='4';
					$("#cardApplicant_div").css('display','none');
					queryNocarConfProxyInfoEdit4(1);
					mapBak.clear();//清空备份map
					for(var o in data.map){  
			        	var obj = new Object();
			        	obj.id = data.map[o].id;
			        	obj.cardapplicant = data.map[o].cardapplicant;
			        	obj.value = data.map[o].value=="null"?"":data.map[o].value;
			        	map.put(obj.id,obj);
			        	mapBak.put(obj.id,obj);
			      	}
					$("#agentType").val(data.AGENTTYPE);
					$("tr[id^=qudaoandlaiyuan0]").css('display','none');
					$("tr[id^=agentType1]").css('display','none');
					$("tr[id^=agentType3]").css('display','none');
					$("tr[id^=agentType4]").css('display','');
					$("#deptCode101").empty();
					$("#deptCode102").empty();
					$("#deptCode102").append("<input type='hidden' id='deptCode' value=''/>");
				}else if ("5"==data.AGENTTYPE){
					oldAgentType ='5';
					$("#cardApplicant_div").css('display','none');
					queryNocarConfProxyInfoEdit4(1);
					mapBak.clear();//清空备份map
					for(var o in data.map){  
			        	var obj = new Object();
			        	obj.id = data.map[o].id;
			        	obj.cardapplicant = data.map[o].cardapplicant;
			        	obj.value = data.map[o].value=="null"?"":data.map[o].value;
			        	map.put(obj.id,obj);
			        	mapBak.put(obj.id,obj);
			      	}
					$("#agentType").val(data.AGENTTYPE);
					$("tr[id^=qudaoandlaiyuan0]").css('display','none');
					$("tr[id^=agentType1]").css('display','none');
					$("tr[id^=agentType3]").css('display','none');
					$("tr[id^=agentType4]").css('display','none');
					$("#deptCode101").empty();
					$("#deptCode102").empty();
					$("#deptCode102").append("<input type='hidden' id='deptCode' value=''/>");
					$('#agentFeeConfig').val(data.AGENTFEECONFIG);
					if(data.AGENTFEECONFIG!=null&&data.AGENTFEECONFIG!=''){
						agentFeeConfigChange();
					}
				}else if("6"==data.AGENTTYPE){
					oldAgentType ='6';
					$('#agentNo').val(data.AGENTNO);
					$('#serviceCode').val(data.SERVICECODE);
					$('#serviceName').val(data.SERVICENAME);
					$('#empNo').val(data.EMPNO);
					$('#empName').val(data.EMPNAME);
					$('#teamCode').val(data.TEAMCODE);
					$('#teamName').val(data.TEAMNAME);
					$('#protocolNo').val(data.PROTOCOLNO);
					$("tr[id^=agentType1]").css('display','');
					$("tr[id^=qudaoandlaiyuan0]").css('display','');
					$('#agentFeeConfig').val(data.AGENTFEECONFIG);
					if(data.AGENTFEECONFIG!=null&&data.AGENTFEECONFIG!=''){
						agentFeeConfigChange();
					}
					/* $("#deptCode101").empty();
					$("#deptCode102").empty();
					$("#deptCode101").append("出单机构：");
					$("#deptCode102").append("<input id='deptCode' readonly='readonly' style=' background-color: #ccc;' class='input_text'><span class='red'>*</span>&nbsp;&nbsp;<input type='button' class='input_button_2' value='请选择' onClick='openDeptDiv()' />");
 */				
				}
				else{
					oldAgentType ='1';
					$('#agentNo').val(data.AGENTNO);
					$('#serviceCode').val(data.SERVICECODE);
					$('#empNo').val(data.EMPNO);
					$('#teamCode').val(data.TEAMCODE);
					$('#teamName').val(data.TEAMNAME);
					$('#protocolNo').val(data.PROTOCOLNO);
					$("tr[id^=qudaoandlaiyuan0]").css('display','');
					$("tr[id^=agentType1]").css('display','');
					$("tr[id^=agentType3]").css('display','none');
					$("tr[id^=agentType4]").css('display','none');
					$("#deptCode101").empty();
					$("#deptCode102").empty();
					$("#deptCode101").append("出单机构：");
					$("#deptCode102").append("<input id='deptCode'  type='text' readonly='readonly' style=' background-color: #ccc;' class='input_text'><span class='red'>*</span>&nbsp;<input type='button'  class='input_button_2' id='searchDeptBtn' value='请选择' onClick='openDeptDiv(1,this)' />");
					$('#deptCode').val(data.DEPTCODE);
				}
				
				$('#specialArran').val(data.SPECIALARRAN);
				$('#status').val(data.STATUS);
				$('#isSeeMoney').val(data.ISSEEMONEY);
				if($('#isSeeMoney').val()=="N"){
					$('#isDredgePay').val(1);
					$('#isDredgePay').attr("disabled",true);
					$("#isDredgePay").css({"background-color": "#ccc"});
				}else{
					$("#isDredgePay").attr("disabled",false);
					$("#isDredgePay").css({"background-color": ""});
				}
				$('#isEpolicy').val(data.ISEPOLICY);
				if(data.EPOLICYINVOICE==''||data.EPOLICYINVOICE==null){
					$('#isEpolicyInvoice').val(2);
				}else{
					$('#isEpolicyInvoice').val(data.EPOLICYINVOICE);
				}
				var isEinvoice=$('#isEpolicyInvoice').val();
				if("1"==isEinvoice){
					$(".CinvockLink").show();
					$("#invockLink").val(data.INVOCKLINK);
					$("#isInsuranceEinvoice").val(data.ISINSURANCEEINVOICE);
					$("#payEinvoice").val(data.PAYEINVOICE);
					isInsurEinvoiceChange();
					$("#einvoiceInfo").show();
				}else{
					$(".CinvockLink").hide();
				}
				invockLinkChange("1")
				$("#dentification").val(data.DENTIFICATION);
				if(data.DREDGEPAY==''||data.DREDGEPAY==null||data.ISSEEMONEY==2){
					$('#isDredgePay').val(1);
				}else{
					$('#isDredgePay').val(data.DREDGEPAY);
				}
				//是不是发送邮件
				if(data.EPOLICYMALI==''||data.EPOLICYMALI==null){
					$('#isEpolicyMali').val(2);
				}else{
					$('#isEpolicyMali').val(data.EPOLICYMALI);
				}
				if((data.EPOLICYMALI)==0||(data.EPOLICYMALI)==2){
					$('#MailTemplateTr').hide();
					$('#sendAccessory').hide();
					$('#sendAccessoryTd').hide();
				}
				if((data.EPOLICYMALI)=="1"){
					$('#sendAccessory').show();
					$('#sendAccessoryTd').show();
					$('#MailTemplateTr').show();
					var ids=new Array(5);
					ids=data.ids;
					if(ids!=null){
						$('input[name=SendAccessoryBox]').each(function(){
							for(i=0;i<ids.length;i++){
								if($(this).val()==ids[i]){
									$(this).attr("checked",true);
								}
							}
						});
					}
				}
				//注销短信模板、短信接收人动态显示
				$('#isCancelMessage').val(data.ISCANCELMESSAGE);
				if(data.ISCANCELMESSAGE=='Y'){
					$('#cancelTemplateTr').show();
					//$('#cancelTemplate').css("background-color","white");
					$('#cancelTemplate').val(data.cancelTemplate_val).attr("disabled",true).css("background-color","rgb(204, 204, 204)");
					$('#isCancelTemplate').val(data.CANCELTEMPLATE);
					$('#cancelReceiverDiv').show();
					$('#cancelTemplateDiv').show();
					$('#cancelReceiver').val(data.CANCELRECEIVER);
				}
				//是不是发送电子保单
				$('#isEpolicy').val(data.ISEPOLICY);
				if((data.ISEPOLICY)=="Y"){
					$('#Download_left').val(data.ISEPOLICY);
					$('#Download_right').show();
					$('#DownloadWay').show();
				}else{
					//rt(12312)
					$('#Download_left').val(data.ISEPOLICY);
					$('#Download_right').hide();
				}
				$('#DownloadWay').val(data.DOWNLOADWAY);
				downloadWayChange("1");
				$('#fileType').val(data.FILETYPE);
				$('#MailTemplate').html(data.MAILTEMPLATE); 
				$('#is_message').val(data.ISMESSAGE);
				if(data.ISMESSAGE=='Y'){
					$('#messageTemplateTr').show();
					//$('#messageTemplate').css("background-color","white");
					$('#messageTemplate').val(data.messageTemplate_val).attr("disabled",true).css("background-color","rgb(204, 204, 204)");
					$('#smsTemplate').val(data.MESSAGETEMPLATE);
					$('#messageReceiverDiv').show();
					$('#smsTemplateDiv').show();
					$('#messageReceiver').val(data.MESSAGERECEIVER);
				}
				if(null!=data.ISPRINTCARD){
					$('#isPrintCard').val(data.ISPRINTCARD);
					if(data.ISPRINTCARD=='Y'){
						$('#cardApplicant').attr("readonly",false);
						$('#cardApplicant').css("background-color","white");
						$('#cardApplicant').val(data.CARDAPPLICANT);
						$('#cardType').attr("readonly",false);
						$('#cardType').css("background-color","white");
						$('#cardType').val(data.CARDTYPE);
					}
				}
				if(data.SPECIALCONFIGTYPE){
					$('#specialConfigType').val(data.SPECIALCONFIGTYPE);
					if(data.SPECIALCONFIGTYPE=='1'){
						specialConfigTypeChange();
					}
				}
				if(data.DEPTCODE!=undefined){
					//广东人员配置信息
					var sale=data.DEPTCODE.substring(0,2);
					if(sale=='44'){
						$('#sale1').show();
						$('#sale2').show();
					}else{
						$('#sale1').hide();
						$('#sale2').hide();
					}
				}
			}else{
				$.message("error", "页面加载失败");
			}
      	}
	});
}
function agentChange(){
	//1、合作伙伴代理3、个人销售业务4、总对总销售业务5、联合出单
	var agentType=$('#agentType').val();
	var dptCode=$("#deptCode").val()
	$('#agentFeeConfig').val('');
	isDisable("empNo", false);
	isDisable("empName", false);
	isDisable("teamCode", false);
	isDisable("teamName", false);
	isDisable("agentNo", false);
	isDisable("protocolNo", false)
	$('input[onclick="openDeptDiv()"]').attr("disabled",false)
	isDisable("serviceCode", false)
	isDisable("serviceName", false)
	isDisable("commRate", false);
	isDisable("businessPerformanceRate", false);
	isDisable("marketPreserveRate", false);
	$('#cRate').html('手续费比例：');
	$('#mRate').html('市场维护费比例：');
	$('#bRate').html('业务绩效比例：');
	isDisable("searchDeptBtn", false);
	$("tr[id^=agentType1]").css('display','none');
	$("tr[id^=agentType3]").css('display','none');
	$("tr[id^=agentType4]").css('display','none');
	$("tr[id^=agentType6]").css('display','none');
	if('1'==agentType){
		$("tr[id^=qudaoandlaiyuan0]").css('display','');
		$("#cardApplicant_div").css('display','');
		$("tr[id^=agentType1]").css('display','');
		$("tr[id^=agentType3]").css('display','none');
		$("tr[id^=agentType4]").css('display','none');
		$("#commRateSpan").empty();
		$("#deptCode101").empty();
		$("#deptCode102").empty();
		$("#deptCode101").append("出单机构：");
		$("#deptCode102").append("<input id='deptCode'  type='text' readonly='readonly' style=' background-color: #ccc;' class='input_text'><span class='red'>*</span>&nbsp;<input type='button'  class='input_button_2' id='searchDeptBtn' value='请选择' onClick='openDeptDiv(1,this)'//>");
	}else if('3'==agentType){
		$("tr[id^=qudaoandlaiyuan0]").css('display','none');
		$("#cardApplicant_div").css('display','none');
		$("tr[id^=agentType1]").css('display','none');
		$("tr[id^=agentType3]").css('display','');
		$("tr[id^=agentType4]").css('display','none');
		$("#commRateSpan").empty();
		$("#commRateSpan").append("销售业务信息未配置,则使用此比例");
		$("#deptCode101").empty();
		$("#deptCode102").empty();
		$("#deptCode102").append("<input type='hidden' id='deptCode' value='' />");
	}else if('4'==agentType){
		$("tr[id^=qudaoandlaiyuan0]").css('display','none');
		$("#cardApplicant_div").css('display','none');
		$("tr[id^=agentType1]").css('display','none');
		$("tr[id^=agentType3]").css('display','none');
		$("tr[id^=agentType4]").css('display','');
		$("#commRateSpan").empty();
		$("#commRateSpan").append("销售业务信息未配置,则使用此比例");
		$("#deptCode101").empty();
		$("#deptCode102").empty();
		$("#deptCode102").append("<input type='hidden' id='deptCode' value='' />");
	}else if ("5" == data.AGENTTYPE){
		$("tr[id^=qudaoandlaiyuan0]").css('display','');
		$("#cardApplicant_div").css('display','none');
		$("tr[id^=agentType1]").css('display','none');
		$("tr[id^=agentType3]").css('display','none');
		$("tr[id^=agentType4]").css('display','none');
		$("#commRateSpan").empty();
		$("#deptCode101").empty();
		$("#deptCode102").empty();
		$("#deptCode101").append("出单机构：");
		$("#deptCode102").append("<input id='deptCode'  type='text' readonly='readonly' style=' background-color: #ccc;' class='input_text' value='"+dptCode+"'><span class='red'>*</span>&nbsp;<input type='button'  class='input_button_2' id='searchDeptBtn' value='请选择' onClick='openDeptDiv(1,this)'//>");
	}else if('6'==agentType){
		$("tr[id^=qudaoandlaiyuan0]").css('display','');
		$("#cardApplicant_div").css('display','');
		$("tr[id^=agentType1]").css('display','');
		$("tr[id^=agentType3]").css('display','none');
		$("tr[id^=agentType4]").css('display','none');
		$("#commRateSpan").empty();
		$("#deptCode101").empty();
		$("#deptCode102").empty();
		$("#deptCode101").append("出单机构：");
		$("#deptCode102").append("<input id='deptCode'  type='text' readonly='readonly' style=' background-color: #ccc;' class='input_text' value='"+dptCode+"'><span class='red'>*</span>&nbsp;<input type='button'  class='input_button_2' id='searchDeptBtn' value='请选择' onClick='openDeptDiv(1,this)'//>");
	}else{
		$("tr[id^=qudaoandlaiyuan0]").css('display','');
		$("#cardApplicant_div").css('display','none');
		$("tr[id^=agentType1]").css('display','');
		$("tr[id^=agentType3]").css('display','none');
		$("tr[id^=agentType4]").css('display','none');
		$("#commRateSpan").empty();
		$("#deptCode101").empty();
		$("#deptCode102").empty();
		$("#deptCode101").append("出单机构：");
		$("#deptCode102").append("<input id='deptCode'  type='text' readonly='readonly' style=' background-color: #ccc;' class='input_text'><span class='red'>*</span>&nbsp;<input type='button'  class='input_button_2' id='searchDeptBtn' value='请选择' onClick='openDeptDiv(1,this)'//>");
	}
	if('6'==agentType || '5'==agentType){
		isDisable("agentFeeConfig", false);
	}else{
		isDisable("agentFeeConfig", true);
	}
}
/**是否可以录入*/
function isDisable (obj,flag){
	//可用
	if(!flag){
		$("#"+obj).attr("disabled",false);
		$("#"+obj).css({"background-color": ""});
	}else{
		//不可用
		$("#"+obj).attr("disabled",true);
		$("#"+obj).css({"background-color": "#ccc"});
	}
}
/**跟单费用配置改变**/
function agentFeeConfigChange(){
	var agentFeeConfig =$('#agentFeeConfig').val();
	var dptCode=$("#deptCode").val()
	/**接口传入*/
	if('1'==agentFeeConfig){
		$('#empNo').val('');
		$('#empName').val('');
		$('#teamName').val('');
		$('#teamCode').val('');
		$('#agentNo').val('');
		$('#protocolNo').val('');
		$('#serviceCode').val('');
		$('#serviceName').val('');
		$('#channleCode_QD').val('');
		$('#channleType').val('');
		$('#newBsnsType').val('');
		$('#deptCode').val('');
		$('#bsnsType').val('');
		isDisable("empNo", true);
		$('input[onclick="openDeptDiv(1,this)"]').attr("disabled",true)
		isDisable("searchDeptBtn", true);
		isDisable("empName", true);
		isDisable("teamCode", true);
		isDisable("teamName", true);
		isDisable("agentNo", true);
		isDisable("protocolNo", true);
		isDisable("serviceCode", true);
		isDisable("serviceName", true)
		$('#cRate').html('手续费比例上限：');
		$('#mRate').html('市场维护费比例上限：');
		$('#bRate').html('业务绩效比例上限：');
		$('#agentType601').hide();
		isDisable("commRate", false);
		isDisable("businessPerformanceRate", false);
		isDisable("marketPreserveRate", false);
		$("tr[id^=qudaoandlaiyuan0]").css('display','none');
		$("tr[id^=agentType1]").css('display','');
		$("tr[id^=agentType6]").css('display','none');
	}else{
		isDisable("empNo", false);
		isDisable("empName", false);
		isDisable("teamCode", false);
		isDisable("teamName", false);
		isDisable("agentNo", false);
		isDisable("protocolNo", false)
		isDisable("serviceCode", false)
		isDisable("serviceName", false)
		$("#deptCode101").empty();
		$("#deptCode102").empty();
		$("#deptCode101").append("出单机构：");
		$("#deptCode102").append("<input id='deptCode'  type='text' readonly='readonly' style=' background-color: #ccc;' value='"+dptCode+"'class='input_text'><span class='red'>*</span>&nbsp;<input type='button'  class='input_button_2' id='searchDeptBtn' value='请选择' onClick='openDeptDiv(1,this)'//>");
		$("tr[id^=qudaoandlaiyuan0]").css('display','');
		$('#cRate').html('手续费比例：');
		$('#mRate').html('市场维护费比例：');
		$('#bRate').html('业务绩效比例：');
		$('#commRate').val('');
		if('2'==agentFeeConfig){
			$("tr[id^=qudaoandlaiyuan0]").css('display','none');
			$('#empNo').val('');
			$('#empName').val('');
			$('#teamName').val('');
			$('#teamCode').val('');
			$('#agentNo').val('');
			$('#protocolNo').val('');
			$('#serviceCode').val('');
			$('#serviceName').val('');
			$('#channleCode_QD').val('');
			$('#channleType').val('');
			$('#newBsnsType').val('');
			$('#deptCode').val('');
			$('#bsnsType').val('');
			$('#businessPerformanceRate').val('');
			$('#marketPreserveRate').val('');
			isDisable("empNo", true);
			$('input[onclick="openDeptDiv(1,this)"]').attr("disabled",true)
			isDisable("searchDeptBtn", true);
			isDisable("empName", true);
			isDisable("teamCode", true);
			isDisable("teamName", true);
			isDisable("agentNo", true);
			isDisable("protocolNo", true);
			isDisable("serviceCode", true);
			isDisable("serviceName", true);
			$('#agentType601').show();
			isDisable("commRate", true);
			isDisable("businessPerformanceRate", true);
			isDisable("marketPreserveRate", true);
		}else{
			$("tr[id^=agentType6]").css('display','none');
			isDisable("commRate", false);
			isDisable("businessPerformanceRate", false);
			isDisable("marketPreserveRate", false);
			$('#agentType601').hide();
		}
		
	}
}

//绑定单选按钮事件，选中某个单选按钮，该按钮所在行高亮显示
function bindradio(){
	$("input[name='prodradio']").click(function(){
		$("input[name='prodradio']").parent().parent().removeClass("table_highlighter");
		$(this).parent().parent().addClass("table_highlighter");
   	});
	$("input[name='partnerradio']").click(function(){
		$("input[name='partnerradio']").parent().parent().removeClass("table_highlighter");
		$(this).parent().parent().addClass("table_highlighter");
   	});
	$("input[name='deptradio']").click(function(){
		$("input[name='deptradio']").parent().parent().removeClass("table_highlighter");
		$(this).parent().parent().addClass("table_highlighter");
   	});
	$("input[name='agentType3checkbox']").click(function(){
		var id= $(this).parent().parent().children(" td:eq(1)").html();
		if($(this).prop("checked")){//选中
			$(this).parent().parent().addClass("table_highlighter");
			var obj = new Object();
			var cardapplicant= $(this).parent().parent().children(" td:eq(9)").html();
			var value= $(this).parent().parent().find("input[name='value']").val();
			obj.id =id;
			obj.cardapplicant = cardapplicant;
			obj.value= value;
			map.put(obj.id,obj);
		}else{//取消选中
			$(this).parent().parent().removeClass("table_highlighter");
			$(this).prop("checked",false);
			map.remove(id);
		}
   	});
	$("input[name='agentType4checkbox']").click(function(){
		var id= $(this).parent().parent().children(" td:eq(1)").html();
		if($(this).prop("checked")){//选中
			$(this).parent().parent().addClass("table_highlighter");
			var obj = new Object();
			var cardapplicant= $(this).parent().parent().children(" td:eq(11)").html();
			var value= $(this).parent().parent().find("input[name='value']").val();
			obj.id =id;
			obj.cardapplicant = cardapplicant;
			obj.value= value;
			map.put(obj.id,obj);
		}else{//取消选中
			$(this).parent().parent().removeClass("table_highlighter");
			$(this).prop("checked",false);
			map.remove(id);
		}
   	});
}
//------------------------------------------ 初始化本页面 结束----------------------------------------------

//统一 关闭  窗口
function closeCurrentDIV(obj){
	$("#"+obj).CloseDiv();	
}

//------------------------------------------ 产品  开始----------------------------------------------
//打开产品窗口
function openProdDiv(pageIndex,obj){
	$('#prodcode').val('');
	$('#proddesc').val('');
	$('#startDate').val('');
	$('#endDate').val('');
	
	$("#"+obj.id).blur();
	queryTradProdInst(pageIndex);
}

//调用拼接参数的方法，并执行查询
function queryTradProdInst(pageIndex){
	var size = 8;
	var code = $('#prodcode').val();
	var desc = $('#proddesc').val();
	var strReg = /^(\d{4})\-(\d{2})\-(\d{2})$/;
	var startDate = $('#startDate').val();
	var endDate = $('#endDate').val();
	var sflag = strReg.test(startDate);
	var eflag = strReg.test(endDate);
	if(null != startDate && "" != startDate){
		if(!sflag){
			$.message("error", "您输入的定义起期格式不正确，格式为：YYYY-MM-DD。请重新选择日期");
			$('#startDate').val('');
			return;
		}
	}
	if(null != endDate && "" != endDate){
		if(!eflag){
			$.message("error", "您输入的定义止期格式不正确，格式为：YYYY-MM-DD。请重新选择日期");
			$('#endDate').val('');
			return;
		}
	}
	queryAllProds({size:size,pageIndex:pageIndex,tradProdCode:code,tradProdDesc:desc,VstartDate:startDate,VendDate:endDate});
}


//查询产品
function queryAllProds(param){
	$.openLoading();
	$.ajax({
		url : "noCarInsure/loadTradProdInst",
		type : 'POST',
		async : true,
		data:param,
		dataType:'json',
		success:function(partnerPage){
			$.closeLoading();
			if($.validate(partnerPage))return;

					var radioObj ="<input class='input_fxk' name='prodradio' type='radio' value=''>";
					var fieldNames = "prodCode,prodName,prodType@TDH,agentType@TDH,epolicyType@TDH,econfirmType@TDH";
					var tableContent = creatTable1(fieldNames,partnerPage,radioObj);
					var tableObj = $("#productTable");
					tableObj.find("tbody").remove();
					tableObj.append(tableContent);
					
					var strPage = creatChannelPage(param.pageIndex,6,partnerPage.maxPage,"17");
					var pageDIV = $("#productPageDIV");
					pageDIV[0].innerHTML="";
					pageDIV.append(strPage);
					
					$("#prodDiv").OpenDiv();
					
					bindradio();
			}
	});
}

//点击“确定” ，选择 产品
function chooseProd(){
	var selectedProd= $("input[name='prodradio']:checked");
	if(selectedProd.length==0){
		$.message("error", "请选择一个产品");
		return;
	}
	var prodCode = selectedProd.parent().parent().children(" td:eq(1)").html();
	var prodName = selectedProd.parent().parent().children(" td:eq(2)").html();
	prodType = selectedProd.parent().parent().children(" td:eq(3)").html();
	$('#prodCode').val(prodCode);
	$('#prodName').val(prodName);
	var agentType = selectedProd.parent().parent().children(" td:eq(4)").html();//销售类型
	$("#agentType").val(agentType);
	epolicyType = selectedProd.parent().parent().children(" td:eq(5)").html();//保单类型
	econfirmType = selectedProd.parent().parent().children(" td:eq(6)").html();//保单类型
	$('#isEpolicy').val('N');
	$('#isEConfirm').val('N');
	$('#isPushedSalesInfo').val('N');
	IsEpolicyChange();
	//1、合作伙伴代理3、个人代理4、总对总代理5、联合出单
	if('1'==agentType){
		$("#cardApplicant_div").css('display','');
		$("tr[id^=qudaoandlaiyuan0]").css('display','');
		$("tr[id^=agentType1]").css('display','');
		$("tr[id^=agentType3]").css('display','none');
		$("tr[id^=agentType4]").css('display','none');
		$("#commRateSpan").empty();
		$("#deptCode101").empty();
		$("#deptCode102").empty();
		$("#deptCode101").append("出单机构：");
		$("#deptCode102").append("<input id='deptCode'  type='text' readonly='readonly' style=' background-color: #ccc;' class='input_text'><span class='red'>*</span>&nbsp;<input type='button'  class='input_button_2' id='searchDeptBtn' value='请选择' onClick='openDeptDiv(1,this)' />");
	}else if('3'==agentType){
		$("#cardApplicant_div").css('display','none');
		$("tr[id^=qudaoandlaiyuan0]").css('display','none');
		$("tr[id^=agentType1]").css('display','none');
		$("tr[id^=agentType3]").css('display','');
		$("tr[id^=agentType4]").css('display','none');
		$("#commRateSpan").empty();
		$("#commRateSpan").append("销售业务信息未配置,则使用此比例");
		$("#deptCode101").empty();
		$("#deptCode102").empty();
		$("#deptCode102").append("<input type='hidden' id='deptCode' value='' />");
	}else if('4'==agentType){
		$("#cardApplicant_div").css('display','none');
		$("tr[id^=qudaoandlaiyuan0]").css('display','none');
		$("tr[id^=agentType1]").css('display','none');
		$("tr[id^=agentType3]").css('display','none');
		$("tr[id^=agentType4]").css('display','');
		$("#commRateSpan").empty();
		$("#commRateSpan").append("销售业务信息未配置,则使用此比例");
		$("#deptCode101").empty();
		$("#deptCode102").empty();
		$("#deptCode102").append("<input type='hidden' id='deptCode' value='' />");
	}else if('5'==agentType){
		$("#cardApplicant_div").css('display','none');
		$("tr[id^=qudaoandlaiyuan0]").css('display','none');
		$("tr[id^=agentType1]").css('display','none');
		$("tr[id^=agentType3]").css('display','none');
		$("tr[id^=agentType4]").css('display','none');
		$("#commRateSpan").empty();
		$("#commRateSpan").append("销售业务信息未配置,则使用此比例");
		$("#deptCode101").empty();
		$("#deptCode102").empty();
		$("#deptCode102").append("<input type='hidden' id='deptCode' value='' />");
		agentType5ChageChearData();
	}else{
		$("#cardApplicant_div").css('display','none');
		$("tr[id^=qudaoandlaiyuan0]").css('display','');
		$("tr[id^=agentType1]").css('display','');
		$("tr[id^=agentType3]").css('display','none');
		$("tr[id^=agentType4]").css('display','none');
		$("#commRateSpan").empty();
		$("#deptCode101").empty();
		$("#deptCode102").empty();
		$("#deptCode101").append("出单机构：");
		$("#deptCode102").append("<input id='deptCode'  type='text' readonly='readonly' style=' background-color: #ccc;' class='input_text'><span class='red'>*</span>&nbsp;<input type='button'  class='input_button_2' id='searchDeptBtn' value='请选择' onClick='openDeptDiv(1,this)' />");
	}
	closeCurrentDIV('prodDiv');
	//清空出单机构
	$("#deptCode").val("");
	$('#sale1').hide();
	$('#sale2').hide();
}
/**方案销售类型为“联合出单”时，清空以下录入数据*/
function agentType5ChageChearData(){
	$('#deptCode').val('');//出单机构
	$('#empNo').val('');//业务员代码
	$('#empName').val('');//业务员名称
	$('#teamCode').val('');//团队代码
	$('#teamName').val('');//团队名称
	$('#agentNo').val('');//代理人代码
	$('#protocolNo').val('');//代理协议号
	$('#serviceCode').val('');//服务代码
	$('#serviceName').val('');//服务名称
}
//------------------------------------------ 产品  结束----------------------------------------------

//------------------------------------------ 合作伙伴 开始----------------------------------------------
//initTradPartners
function queryPartner(param){
	$.openLoading();
	$.ajax({
		url : "noCarInsure/loadChannelInfo1",
		type : 'POST',
		async : true,
		data:param,
		dataType:'json',
		success:function(partnerPage){
			$.closeLoading();
			if($.validate(partnerPage))return;
					var radioObj ="<input class='input_fxk' name='partnerradio' type='radio' value=''>";
					var fieldNames = "channelCode@TDH,channelCode,channelName,clientNo@TDH,thirdPlan@TDH,channelFlag@TDH";
					var tableContent = creatTable1(fieldNames,partnerPage,radioObj);
					var tableObj = $("#TradPartnerTable");
					tableObj.find("tbody").remove();
					tableObj.append(tableContent);
					
					var strPage = creatChannelPage2(param.pageIndex,6,partnerPage.maxPage,"16");
					var pageDIV = $("#TradPartnerPageDIV");
					pageDIV[0].innerHTML="";
					pageDIV.append(strPage);
					
					$('#tradPartnerDiv').OpenDiv(); 
					
					bindradio();
			}
	});
}  



//打开合作伙伴 div 方法
function openThisDiv(pageIndex,obj){
	if(($.trim($('#prodCode').val())).length==0){
		$.message('error',"请先选择产品");
		return;
	}
	$('#channelCode').val('');
	$('#channelName').val('');
	$("#"+obj.id).blur();
	queryTradPartners(pageIndex);
}


//拼接页面查询参数  查询合作伙伴
function mergePartnerParams(pageIndex){
	var size = 8;
	var partnerNo = $('#channelCode').val();
	var partnerName = $('#channelName').val();
	queryPartner({pageIndex:pageIndex,size:size,channelCode:partnerNo,channelName:partnerName});
}



//查询 合作伙伴
function queryTradPartners(pageIndex){
	mergePartnerParams(pageIndex);
}
/**网销专属方案处理*/
function channelChannel(flag){
	if(flag=='1'){
		$('span[name="wxflag"]').hide()
		$('#state').removeAttr("readonly");
	}else{
		$('span[name="wxflag"]').show()
		$("#state").attr("readonly","readonly");
	}
}

//点击“确定”按钮，选择合作伙伴
function choosePartner(){
	var selectedPartner = $("input[name='partnerradio']:checked");
	if(selectedPartner.length==0){
		$.message("error", "请选择一个合作伙伴");
		return;
	}
	var pno = selectedPartner.parent().parent().children(" td:eq(1)").html();
	var flag = selectedPartner.parent().parent().children("td:eq(6)").html();
	channelFlag=flag;
	channelChannel(flag);
	$('#partnerCode').val(pno);
	
	if(pno!=oldPartnerNo){//如果合作伙伴代码变了
		$("#agentType3Table").find("tbody").remove();
		$("#agentType3TablePageDIV")[0].innerHTML="";
		$("#agentType4Table").find("tbody").remove();
		$("#agentType4TablePageDIV")[0].innerHTML="";

	}
	var thirdPlan = selectedPartner.parent().parent().children(" td:eq(5)").html();
	closeCurrentDIV('tradPartnerDiv');
	//清空出单机构
	$("#deptCode").val("");
	$('#isThirdPlan').val(thirdPlan);
	$('#sale1').hide();
	$('#sale2').hide();
}

function clearParams(){
	$('#tradPartnerNo').val('');
	$('#tradPartnerName').val('');
	$('#inspno').val('');
	$('#inspname').val('');
}
//------------------------------------------ 合作伙伴 结束----------------------------------------------
//------------------------------------------ 出单机构 开始----------------------------------------------
//打开机构窗口
function openDeptDiv(pageIndex,obj){
	
	if($.trim($('#partnerCode').val()).length==0){
		$.message("error", "请先选择合作伙伴代码");
		return;
	}
	
	$('#deptcode').val('');
	$('#deptcnname').val('');
	$("#"+obj.id).blur();
	queryCoreDept(pageIndex);
}

//调用拼接参数的方法，并执行查询
function queryCoreDept(pageIndex){
	var size = 8;
	var code = $('#deptcode').val();
	var name = $('#deptcnname').val();
	var pno = $('#partnerCode').val();
	queryAllDepts({size:size,pageIndex:pageIndex,deptCode:code,deptCNname:name,channelCode:pno});
}


//查询机构
function queryAllDepts(param){
	$.openLoading();
	$.ajax({
		url : "noCarInsure/loadCoreDept",
		type : 'POST',
		async : true,
		data:param,
		dataType:'json',
		success:function(deptPage){
			$.closeLoading();
			if($.validate(deptPage))return;

					var radioObj ="<input class='input_fxk' name='deptradio' type='radio' value=''>";
					var fieldNames = "deptCode,deptCNname";
					var tableContent = creatTable1(fieldNames,deptPage,radioObj);
					var tableObj = $("#deptTable");
					tableObj.find("tbody").remove();
					tableObj.append(tableContent);
					
					var strPage = creatChannelPage3(param.pageIndex,6,deptPage.maxPage,"18");
					var pageDIV = $("#deptPageDIV");
					pageDIV[0].innerHTML="";
					pageDIV.append(strPage);
					
					$("#deptDiv").OpenDiv();
					
					bindradio();
			}
	});
}

//点击“确定” ，选择 出单机构
function chooseDept(){
	var selectedDept= $("input[name='deptradio']:checked");
	if(selectedDept.length==0){
		$.message("error", "请选择一个出单机构");
		return;
	}
	var deptCode = selectedDept.parent().parent().children(" td:eq(1)").html();
	//广东分公司销售人员信息配置
	var sale=deptCode.substring(0,2);
	if(sale=='44'){
		$('#sale1').show();
		$('#sale2').show();
	}else{
		$('#sale1').hide();
		$('#sale2').hide();
	}
	$('#deptCode').val(deptCode);
	closeCurrentDIV('deptDiv');
	$('#deptCode').val(deptCode);
	closeCurrentDIV('deptDiv');
}

//------------------------------------------ 出单机构 结束----------------------------------------------

//添加 投保方案
function checkAndExcute(){
	var planCode = $('#planCode').val();
	var planName = $.trim($('#planName').val());
	if(planName.length==0){
		$.message("error", "请输入投保方案名称");
		$('#planName').focus();
		return;
	}
	var prodCode = $.trim($('#prodCode').val());
	if(prodCode.length==0){
		$.message("error", "请选择产品编号");
		$('#prodCode').focus();
		return;
	}
	var partnerCode = $.trim($('#partnerCode').val());
	if(partnerCode.length==0){
		$.message("error", "请选择合作伙伴代码");
		$('#partnerCode').focus();
		return;
	}
	var channelCode = $.trim($('#channelCodeQD').val());
	var channelType = $.trim($('#channelType').val());
	var newBsnsType = $.trim($('#newBsnsType').val());
	var bsnsType = $.trim($('#bsnsType').val());
	var agentFeeConfig=$("#agentFeeConfig").val();
	var agentType_val= $("#agentType").val();
	//1、合作伙伴代理3、个人代理4、总对总代理5、联合出单
	var deptCode = $.trim($('#deptCode').val());
	if(agentType_val=='1'&&channelFlag!='1'){
		if(deptCode.length==0){
			$.message("error", "请选择出单机构");
			$('#deptCode').focus();
			return;
		}
		if(channelCode.length==0){
			$.message("error", "请选择归属渠道");
			$('#channelCodeQD').focus();
			return;
		}
		if(channelType.length==0){
			$.message("error", "请选择渠道类型");
			$('#channelType').focus();
			return;
		}
		if(newBsnsType.length==0){
			$.message("error", "请选择新业务来源");
			$('#newBsnsType').focus();
			return;
		}
		if(bsnsType.length==0){
			$.message("error", "请选择旧业务来源");
			$('#bsnsType').focus();
			return;
		}
	}
	//是否回执
	var isReceipt = $.trim($('#isReceipt').val()); //2015年6月1日11:56:40 wangyan add
	var receiptType = $('#receiptType').val();
	if('Y'== isReceipt){
		if($('#receiptType').val() == ""){
			$.message("error", "请选择回执类型");
			return;
		}
	}else if('N'== isReceipt){
		receiptType="";
	}
	
	var commRate = $.trim($('#commRate').val());
	var businessPerformanceRate=$.trim($('#businessPerformanceRate').val());
	var marketPreserveRate=$.trim($('#marketPreserveRate').val());
	var totalFee=0;
	if(agentFeeConfig!='2'){
		if(agentFeeConfig=='1'){
			if(commRate.length==0){
				$.message("error", "请输入手续费比例上限");
				$('#commRate').focus();
				return;
			}else{
			    //小数点. 后面最多保留4位小数，根据数据库 手续费比例精度（20,4)
			    var reg = /^([1-9]\d{0,15}|0)(\.\d{1,6})?$/;
			    var resultFlag1 = reg.test(commRate);
			    if(!resultFlag1){
			    	$.message("error","手续费比例上限为长度不超过16位数字且最多保留6位小数的有效数字");
			    	return;
			    }
			    if(!(commRate>=0 && commRate<=1)){
			    	$.message("error","手续费比例上限：只能录入大于等于0且小于等于1的数字！");
			    	return;
			    }
			}
			//业务绩效比例，市场维护比例
			if(marketPreserveRate.length==0){
				$.message("error", "请输入市场维护比例上限");
				$('#marketPreserveRate').focus();
				return;
			}else{
			 	var reg=/^0(\.\d{0,6})?$/;
			    var resultFlag1 = reg.test(marketPreserveRate);
			    if(!resultFlag1){
			    	$.message("error","市场维护比例上限：只能录入0到1之间的有效数字（最多6位小数）");
			    	return;
			    }
			}
			if(businessPerformanceRate.length==0){
				$.message("error", "请输入业务绩效比例上限");
				$('#businessPerformanceRate').focus();
				return;
			}else{
				var reg=/^0(\.\d{0,6})?$/;
			    var resultFlag1 = reg.test(businessPerformanceRate);
			    if(!resultFlag1){
			    	$.message("error","业务绩效比例上限：只能录入0到1之间的有效数字（最多6位小数）");
			    	return;
			    }
			}
		}else{
			if(commRate.length==0){
				$.message("error", "请输入手续费比例");
				$('#commRate').focus();
				return;
			}else{
			    //小数点. 后面最多保留4位小数，根据数据库 手续费比例精度（20,4)
			    var reg = /^([1-9]\d{0,15}|0)(\.\d{1,6})?$/;
			    var resultFlag1 = reg.test(commRate);
			    if(!resultFlag1){
			    	$.message("error","手续费比例为长度不超过16位数字且最多保留6位小数的有效数字");
			    	return;
			    }
			    if(!(commRate>=0 && commRate<=1)){
			    	$.message("error","手续费比例：只能录入大于等于0且小于等于1的数字！");
			    	return;
			    }
			    totalFee=parseFloat(commRate);
			}
			//业务绩效比例，市场维护比例
			if(marketPreserveRate.length==0){
				$.message("error", "请输入市场维护比例");
				$('#marketPreserveRate').focus();
				return;
			}else{
			 	var reg=/^0(\.\d{0,6})?$/;
			    var resultFlag1 = reg.test(marketPreserveRate);
			    if(!resultFlag1){
			    	$.message("error","市场维护比例：只能录入0到1之间的有效数字（最多6位小数）");
			    	return;
			    }
			    totalFee=totalFee+parseFloat(marketPreserveRate);
			}
			if(businessPerformanceRate.length==0){
				$.message("error", "请输入业务绩效比例");
				$('#businessPerformanceRate').focus();
				return;
			}else{
				var reg=/^0(\.\d{0,6})?$/;
			    var resultFlag1 = reg.test(businessPerformanceRate);
			    if(!resultFlag1){
			    	$.message("error","业务绩效比例：只能录入0到1之间的有效数字（最多6位小数）");
			    	return;
			    }
			    totalFee=totalFee+parseFloat(businessPerformanceRate);
			}
			if(totalFee>=1){
				$.message("error","市场维护费比例、业务绩效比例、手续费比例之和必须小于1");
		    	return;
			}
		}
	}
	//注销短信
	var isCancelMessage=$('#isCancelMessage').val();
	var cancelReceiver= $.trim($('#cancelReceiver').val());
	var cancelTemplate_val= $.trim($('#cancelTemplate').val());
	var cancelTemplate = $.trim($('#isCancelTemplate').val());
	if(cancelTemplate_val!=null){
		cancelTemplate_val=encodeURI(cancelTemplate_val);
	}
	if(isCancelMessage=="Y"){
		if(cancelReceiver.length==0){
			$.message("error", "请选择注销短信接收人");
			return;
		}
		if(cancelTemplate_val.length==0){
			$.message("error", "注销短信模板配置不能为空");
			return;
		}
	}else{
		cancelTemplate='';
		cancelReceiver='';
	}
	var status = $.trim($('#status').val());
	if('3'==agentType_val||('4'==agentType_val&&channelFlag!='1')){
		if(oldAgentType==agentType_val&&oldPartnerNo==partnerCode){
			if(status==1){//状态为有效
				if(mapBak.isEmpty()){
					$.message("error", "原方案未配置销售业务信息,该方案不能置为有效");
					return;
				}
			}
		}else{
			if(status==1){//状态为有效
				$.message("error", "产品销售类型更改或合作伙伴更改,改方案不能置为有效");
				return;
			}
		}
	}
	//1、合作伙伴代理3、个人代理4、总对总代理
	var serviceCode='';
	var empNo='';
	var teamCode='';
	var teamName='';
	var agentNo='';
	var protocolNo ='';
	var agentTypeListStr='';
	serviceCode = $.trim($('#serviceCode').val());
	teamCode = $.trim($('#teamCode').val());
	teamName = $.trim($('#teamName').val());
	protocolNo = $.trim($('#protocolNo').val());
	empNo = $.trim($('#empNo').val());
	var isPushedSalesInfo = $.trim($('#isPushedSalesInfo').val());
	if($('#isThirdPlan').val()!='1'&&agentType_val=='6'){
		$.message('error',"此合作伙伴不支持接口传入方案");
		return;
	}
	if(agentType_val =='1' && channelFlag =='1' && 'N' == isPushedSalesInfo && status == 1){
		$.message("error", "该方案为网销专属方案，推送销售信息后才能修改为有效");
		return;
	}
	if(agentType_val=='1'&&channelFlag!='1'){
		if(serviceCode.length==0){
			$.message("error", "请输入服务代码");
			$('#serviceCode').focus();
			return;
		}
		if(empNo.length==0){
			$.message("error", "请输入业务员代码");
			$('#empNo').focus();
			return;
		}
		//原业务来源为19002-代理或19003-经纪，则代理人代码和代理协议号必填，其他非必填
		if(bsnsType=="19002"||bsnsType=="19003"){
			agentNo = $.trim($('#agentNo').val());
			if(agentNo.length==0){
				$.message("error", "请输入代理人代码");
				$('#agentNo').focus();
				return;
			}
			if(protocolNo.length==0){
				$.message("error", "请输入代理协议号");
				$('#protocolNo').focus();
				return;
			}
		}
	}
	
	//是否电子保单
	var isEpolicy_val = $.trim($('#isEpolicy').val());
	var $DownloadWay_val='';
	if(isEpolicy_val==''){
		 $.message("error", "请选择是否电子保单");
		return;
	}else if(isEpolicy_val=='Y'){
		 $DownloadWay_val=$.trim($('#DownloadWay').val());
	}else{
		$DownloadWay_val='';
	}
	 //是否发送电子发票
	var $isEpolicyInvoice=$.trim($('#isEpolicyInvoice').val());
	if( $isEpolicyInvoice==''){
		$.message("error","请选择是否发送电子发票");
		return ;
	}
	 var invockLink ="";
	 var  isInsuranceEinvoice=''
	 var payEinvoice=''
	if($isEpolicyInvoice=='1'){
		invockLink=$("#invockLink").val();
		payEinvoice=$("#payEinvoice").val();
		isInsuranceEinvoice=$("#isInsuranceEinvoice").val();
	}
	var dentification=$('#dentification').val();
	//是否开通支付平台
	var $isDredgePay=$.trim($('#isDredgePay').val());
	//是否见费出单
	var isSeeMoney = $.trim($('#isSeeMoney').val());
	if($isDredgePay==''){
		$.message('error',"请选择是否开通支付平台");
		return;
	}
	if(isSeeMoney=="N"){
		$isDredgePay="";
	}
	//是否发送邮件
	var $isEpolicyMali=$.trim($('#isEpolicyMali').val());
	//邮件模板
	var $MailTemplate=$.trim($('#MailTemplate').val());
	//转码，可能会传入html的数据
	if($MailTemplate!=null){
		$MailTemplate=encodeURI($MailTemplate);
	}
	//获取附加数组
	var selectAccessorys=$('input[name=SendAccessoryBox]:checked');
	//定义一个转换后的字符串
	var selectAccessorylistStr='';
	//判断数组长度
	if(selectAccessorys.length!=0){
		//循环添加
		selectAccessorys.each(function(i){
			var object=new Object();
			object.id=$(this).val();
			map.put(object.id,object);
		});
	}
	//判断map是否为空
	if(!map.isEmpty()){
		//定义list
		var selectAccessorylist =new  Array();
		//循环k值
		for(i in map.keys()){
			//得到key
			var key=map.keys()[i];
			//得到值
			selectAccessorylist.push(map.get(key));
		}
		//转换成字符串
		selectAccessorylistStr=JSON.stringify(selectAccessorylist);
	}
	//是否发送邮件
	if($isEpolicyMali=='1'){
		if($.trim($('#MailTemplate').val()).length==0){
			$.message('error',"请输入邮件模板配置");
			$('#MailTemplate').focus();
			return ;
		}
	}else{
		$MailTemplate="";
		selectAccessorylistStr="";
	}
	var $isEpolicyMali=$.trim($('#isEpolicyMali').val());
	
	//当“是否打印单证”的值为“是”时，单证领用人可输入
	var isPrintCard_val = $.trim($('#isPrintCard').val());
	var cardType_val = $("#cardType").val();
	var cardApplicant_val =$.trim($('#cardApplicant').val());
	if(isPrintCard_val==''){
		$.message("error", "请选择是否打印单证");
		return;
	}else if(isPrintCard_val=="Y"){
		if(cardType_val==''){
			$.message("error", "单证类型不能为空");
			$('#cardType').focus();
			return;
		}
		if(agentType_val!='3'&&agentType_val!='4'){
			if($.trim($('#cardApplicant').val()).length==0){
				$.message("error", "单证领用人不能为空");
				$('#cardApplicant').focus();
				return;
			}
		}
	}
	//当“是否发送短信”的值为“是”时，短信模板配置
	var isMessage_val = $.trim($('#is_message').val());
	if(isMessage_val=='Y'){
		if($('#messageReceiver').val()==""){
			$.message("error", "请选择承保短信接收人");
			return;
		}
		if($.trim($('#messageTemplate').val()).length==0){
			$.message("error", "承保短信模板配置不能为空");
			$('#messageTemplate').focus();
			return;
		}
	}
	//是否回执
	var isedrno = $.trim($('#isedrno').val()); 
	//是否电子保函
	var isEConfirm = $('#isEConfirm').val();
	var isPushedSalesInfo = $('#isPushedSalesInfo').val();
	var edrnoType = $('#edrnoType').val();
	if('Y'== isedrno){
		if($('#isedrno').val() == ""){
			$.message("error", "请选择是否电子批单");
			return;
		}
	}else if('N'== isReceipt){
		edrnoType="";
	}
	var poolInsureCompany="";
	var poolProcotol ="";
	var poolProcotolNo = "";
	var poolIssueFlag = "";
	var poolAgentRate = "";
	var poolRate = "";
	var poolInsureAmount = "";
	var poolRole = "";
	
	var specialArran = $.trim($('#specialArran').val());
	var messageTemplate_val =$.trim($('#smsTemplate').val());
	var messageReceiver_val = $('#messageReceiver').val();
	 if(isMessage_val=='N'){//如果发送短信选择否，短信模板和接收人应当是空 
		 messageTemplate_val="";
		 messageReceiver_val="";
     }
	var oldPlanNo_val = '${param.planCode}';
	var arr='';
	var arr1 = new Array(); 
	var sale=deptCode.substring(0,2);
	
	var specialConfigType=$('#specialConfigType').val();
	 if(specialConfigType=='1'){
		 specialArran='';
	 }
		/**是否上线产品*/
		var isProprod=false;
		if($("#isProprod").is(':checked')){
			isProprod=true;
		}
	if(sale=='44'){
		// if(!salemap.get('1')){
			//$.message("error", "请配置一条销售信息");
			//return
		//} 
		for (var i = 1; i <= 5; i++) {
			if(salemap.get(i)){
				arr1.push(salemap.get(i));
			}
		}
		 arr=JSON.stringify(arr1);
	}
	excuteAdd({
		isCancelMessage:isCancelMessage,cancelReceiver:cancelReceiver,cancelTemplate:cancelTemplate,
		planType:'2',
		saleArry:arr,
		prodCode     :prodCode,
		planName     :planName,
		partnerCode  :partnerCode ,
		channelCode  :channelCode,
		channelType  :channelType ,
		serviceCode  :serviceCode ,
		commRate     :commRate,
		isSeeMoney   :isSeeMoney ,
		empNo        :empNo ,
		teamCode     :teamCode,
		teamName     :teamName,
		bsnsType     :bsnsType ,
		newBsnsType  :newBsnsType ,
		deptCode     :deptCode,
		agentNo      :agentNo ,
		specialArran :specialArran ,
		status       :status ,
		isMessage :isMessage_val,
		messageTemplate:messageTemplate_val,
		messageReceiver:messageReceiver_val,
		prodType	 :prodType,
		protocolNo   :protocolNo,
		isEpolicy    :isEpolicy_val,
		isPrintCard  :isPrintCard_val,
		cardType     :cardType_val,
		cardApplicant:cardApplicant_val,
		oldPlanNo:oldPlanNo_val,
		oldAgentType:oldAgentType,
		EpolicyInvoice:$isEpolicyInvoice,
		DredgePay:$isDredgePay,
		EpolicyMali:$isEpolicyMali,
		MailTemplate:$MailTemplate,
		selectAccessorylistStr:selectAccessorylistStr,
		DownloadWay:$DownloadWay_val,
		agentType:agentType_val,
		agentFeeConfig:agentFeeConfig,
		businessPerformanceRate:businessPerformanceRate,
		marketPreserveRate:marketPreserveRate,
		specialConfigType:specialConfigType,
		isProprod:isProprod
		,invockLink:invockLink,dentification:dentification
		,isReceipt:isReceipt,receiptType:receiptType,
		isedrno:isedrno,edrnoType:edrnoType,isInsuranceEinvoice:isInsuranceEinvoice,payEinvoice:payEinvoice,channelFlag:channelFlag,
		isEConfirm:isEConfirm,isPushedSalesInfo:isPushedSalesInfo});
}

//执行添加
function excuteAdd(param){
	$.openLoading();
	$.ajax({
		url : "noCarInsure/copyAddTradPlan",
		type : 'POST',
		async : true,
		data:param,
		dataType:'json',
		success:function(data){
			$.closeLoading();
			if("success"==data.result&&""!=data.message){
				if(data.data.AgentType=="1"){
					$.message("success", data.message);
					back();
				}else if(data.data.AgentType=="3"){
					$.message("success", data.message);
					window.location.href='<%=path%>/noCarInsure/edit?planCode='+data.data.InsuPlanNo;
				}else if(data.data.AgentType=="4"){
					$.message("success", data.message);
					window.location.href='<%=path%>/noCarInsure/edit?planCode='+data.data.InsuPlanNo;
				}else if(data.data.agentFeeConfig=='2'){
					$.message("success", data.message);
					window.location.href='<%=path%>/noCarInsure/edit?planCode='+data.data.InsuPlanNo;
				}else{
					$.message("success", data.message);
					back();
				}
	    	}
			if("fail"==data.result){
	    		$.message("error", "系统错误,请联系管理员");
	    	}
			if("error"==data.result&&""!=data.message){
	    		$.message("error", data.message);
	    	}
		}
	});
}

//返回
function back(){
		this.location.href = "<%=path%>/noCarInsure/success?flag=addtrue";
}

function clearNoNum(event,obj){ 
    //响应鼠标事件，允许左右方向键移动 
    event = window.event||event; 
    if(event.keyCode == 37 | event.keyCode == 39){ 
        return; 
    } 
    //先把非数字的都替换掉，除了数字和. 
    obj.value = obj.value.replace(/[^\d.]/g,""); 
    //必须保证第一个为数字而不是. 
    obj.value = obj.value.replace(/^\./g,""); 
    //保证只有出现一个.而没有多个. 
    obj.value = obj.value.replace(/\.{2,}/g,"."); 
    //保证.只出现一次，而不能出现两次以上 
    obj.value = obj.value.replace(".","$#$").replace(/\./g,"").replace("$#$","."); 
} 
function checkNum(obj){ 
    //为了去除最后一个. 
    obj.value = obj.value.replace(/\.$/g,""); 
} 


//返回按钮
function goBack(){
	this.location.href = "<%=path%>/noCarInsure/list";
}

//当“是否发送短信”的值为“是”时，短信模板配置可输入
function checkIsMessage(){
	var value = $('#is_message').val();
	if(value=='Y'){
		$('#messageTemplateTr').show();
		//$('#messageTemplate').css("background-color","white");
		$('#messageTemplate').attr("disabled",true).css("background-color","rgb(204, 204, 204)")
		$('#messageReceiverDiv').show();
		$("#messageTemplate").val("");
		$('#smsTemplateDiv').show();
	}else{
		$('#messageTemplateTr').hide();
		$('#messageTemplate').val('');
		$('#messageReceiverDiv').hide();
		$("#smsTemplate").val('');
		$('#smsTemplateDiv').hide();
	}
}
//展示选中的承保短信模板内容
function changeIsMessageTemplate(){
	var value = $('#smsTemplate').val();
	if(value ==null || "" == value || "0" == value){
		$('#messageTemplate').val("");
		return false;
	}
	 $.ajax({
		 	url : "<%=path%>/noCarInsure/loadTemplate",
			type : 'POST',
			async : true,
			dataType:'json',
			data:{smsTemplateCode:value},
			success : function(obj) {
				var smsTemplate = obj;
				$('#messageTemplate').val(obj.smsTemplateText);
			}
	});
}
//------------------------------------------配置代理信息开始--------------------------------------------
//统一 关闭  窗口
function closeNocarAgentTypeDiv(obj){
	$("#"+obj).CloseDiv();	
}
//打开产品窗口
function openNocarAgentType3Div(pageIndex,obj){
	var planno = $("#planCode").val();
	if(planno==""){
		$.message("error", "请先保存投保方案");
		return;
	}
}

function openNocarAgentType4Div(pageIndex,obj){
	var planno = $("#planCode").val();
	if(planno==""){
		$.message("error", "请先保存投保方案");
		return;
	}
}

//----编辑页面的查询
function queryNocarConfProxyInfoEdit3(pageIndex){
	var size = 5;
	var insplanno = $('#hidepno').val();
	var agentType ="3";
	loadNocarConfigureInfoEdit3({size:size,pageIndex:pageIndex,insuPlanNo:insplanno,agentType:agentType});
}
function loadNocarConfigureInfoEdit3(param){
	$.ajax({
		url : "noCarInsure/loadConfProxyInfoEdit",
		type : 'POST',
		async : true,
		data:param,
		dataType:'json',
		success:function(partnerPage){
			$.closeLoading();
			if($.validate(partnerPage))return;

				var fieldNames = "USERCODE,USERNAME,DPTCDE,SERVICECODE,EMPNO,CARDAPPLICANT,TEAMCODE,CHANNLECODE@TDH,CHANNLECODEDES,CHANNLETYPE@TDH,CHANNLETYPEDES,NEWBSNSTYPE@TDH,NEWBSNSTYPEDES,CATEGORYCODE@TDH,CATEGORYCODEDES,AGENTNO,PROTOCOLNO,COMMRATE,MARKETRATE,BUSRATE";
				var tableContent = creatTable1(fieldNames,partnerPage);
				var tableObj = $("#agentType3Table");
				tableObj.find("tbody").remove();
				tableObj.append(tableContent);
				
				var strPage = creatChannelPage3(param.pageIndex,6,partnerPage.maxPage,"35");
				var pageDIV = $("#agentType3TablePageDIV");
				pageDIV[0].innerHTML="";
				pageDIV.append(strPage);
				
			}
	});
}
function queryNocarConfProxyInfoEdit4(pageIndex){
	var size = 5;
	var insplanno = $('#hidepno').val();
	var agentType ="4";
	loadNocarConfigureInfoEdit4({size:size,pageIndex:pageIndex,insuPlanNo:insplanno,agentType:agentType});
}
function loadNocarConfigureInfoEdit4(param){
	$.ajax({
		url : "noCarInsure/loadConfProxyInfoEdit",
		type : 'POST',
		async : true,
		data:param,
		dataType:'json',
		success:function(partnerPage){
			$.closeLoading();
			var flang=false;
			var fieldNames ;
			if($.validate(partnerPage))return;
			$.each(partnerPage.data, function(k, v){
			 if(v.TRANSTYPE=='1'){
				 flang=true;
			 }
			 return false; 
			});
			if(flang){
				fieldNames= "BRANCH,BRANCHNAME,USERCODE,USERNAME,ZONE,DPTCDE,SERVICECODE,EMPNO,CARDAPPLICANT,TEAMCODE,CHANNLECODE@TDH,CHANNLECODEDES,CHANNLETYPE@TDH,CHANNLETYPEDES,NEWBSNSTYPE@TDH,NEWBSNSTYPEDES,CATEGORYCODE@TDH,CATEGORYCODEDES,AGENTNO,PROTOCOLNO,COMMRATE,MARKETRATE,BUSRATE";
				$("#agentType4Table tr:eq(1) td:eq(0)").attr("colspan",17).siblings().remove();
			}else{
			    //先删除表头
					$("#agentType4Table tr th:eq(2)").remove();
					$("#agentType4Table tr th:eq(2)").remove();
					fieldNames = "BRANCH,BRANCHNAME,ZONE,DPTCDE,SERVICECODE,EMPNO,CARDAPPLICANT,TEAMCODE,CHANNLECODE@TDH,CHANNLECODEDES,CHANNLETYPE@TDH,CHANNLETYPEDES,NEWBSNSTYPE@TDH,NEWBSNSTYPEDES,CATEGORYCODE@TDH,CATEGORYCODEDES,AGENTNO,PROTOCOLNO,COMMRATE,MARKETRATE,BUSRATE";
					$("#agentType4Table tr:eq(1) td:eq(0)").attr("colspan",17).siblings().remove();
			}
				var tableContent = creatTable1(fieldNames,partnerPage);
				var tableObj = $("#agentType4Table");
				tableObj.find("tbody").remove();
				tableObj.append(tableContent);
				
				var strPage = creatChannelPage3(param.pageIndex,6,partnerPage.maxPage,"37");
				var pageDIV = $("#agentType4TablePageDIV");
				pageDIV[0].innerHTML="";
				pageDIV.append(strPage);
				
			}
	});
}
	function CheckedSendMail(){
		var ChecdedMail=$("#isEpolicyMali").val();
		if(ChecdedMail==1){
			if(emailMap.elements.length==0){
				emailTemplate();
			}
			$("#MailTemplateTr").show();
			$('#MailTemplate').html("");
			$("#sendAccessory").show();
			$("#sendAccessoryTd").show();
			$('#SendAccessoryBox').show();
			setEmailTemplate();
		}else{
			$("#MailTemplateTr").hide();
			$("#sendAccessory").hide();
			$("#sendAccessoryTd").hide();
		}
	}
	function IsEpolicyChange(){
		var $IsEpolicy =$.trim($('#isEpolicy').val());
		var $Download_right=$('#Download_right');
		if($IsEpolicy=='Y'){
			$Download_right.show();
				if(!epolicyType){
					 $.message("warn", "此产品未配置电子保单，请悉知。如需配置请联系管理员");
				}
		}else{
			$Download_right.hide();
		}
		var isEpolicyMali =$('#isEpolicyMali').val();
		if(isEpolicyMali=='1'){
		  	setEmailTemplate();
		}
	}
	//是否生成电子保函
	function IsEconfirmChange(){
		var $isEConfirm =$.trim($('#isEConfirm').val());
		if($isEConfirm=='Y'){
			if(!econfirmType){
				 $.message("warn", "此产品未配置电子保函，请悉知。如需配置请联系管理员");
			}
		}
	}
	function SeeMoneyChange(){
		var isSeeMoney =$('#isSeeMoney').val();
		if(isSeeMoney=="N"){
			$('#isDredgePay').val(1);
			$('#isDredgePay').attr("disabled",true);
			$("#isDredgePay").css({"background-color": "#ccc"});
		}else{
			$("#isDredgePay").attr("disabled",false);
			$("#isDredgePay").css({"background-color": ""});
		}
	}
	function emailTemplate(){
		$.ajax({
			url : "<%=path%>/noCarInsure/queryEmailTempList?"+new Date().getTime(),
			type : 'POST',
			async : false,
			data:{},
			dataType:'json',
			success:function(data){
				var templates=data.templates;
				if(templates){
					for (var i = 0; i < templates.length; i++) {
						emailMap.put(templates[i].selKey,templates[i].emailTemplate);						
					}
				}

			}
		});
	}
	//动态设置邮件模板
	function setEmailTemplate(flag){
		if(emailMap.elements.length==0){
			emailTemplate();
		}
		if(flag=='1'){
			return;
		}
		var selKey='';
		var isEpolicy=$("#isEpolicy").val();
		var DownloadWay=$("#DownloadWay").val();
		var fileType=$("#fileType").val();
		var isEpolicyInvoice=$("#isEpolicyInvoice").val();
		selKey=isEpolicy;
		if(isEpolicy=='Y'){
			selKey=selKey+'-'+DownloadWay;
		}else{
			selKey=selKey+'-';
		}
		if(isEpolicy=='Y'&&DownloadWay=='1'){
			selKey=selKey+'-'+fileType;
		}else{
			selKey=selKey+'-';
		}
		selKey=selKey+'-'+isEpolicyInvoice;
		var invockLink=$('#invockLink').val();
		if(isEpolicyInvoice=='1'&&invockLink!='S'){
			selKey=selKey+'-'+invockLink;
		}else{
			selKey=selKey+'-';
		}
		var selectAccessorys=$('input[name=SendAccessoryBox]').get(0);
		if(isEpolicy=='Y'){
			if(selectAccessorys.checked){
				selKey=selKey+'-'+'Y';
			}else{
				selKey=selKey+'-'+'N';
			}
		}else{
			selKey=selKey+'-';
		}
		if(emailMap.get(selKey)){
			$('#MailTemplate').val(emailMap.get(selKey));
		}else{
			$('#MailTemplate').val('');
		}
	}
	//文件方式改变
	function fileTypeChange(){
		var isEpolicyMali =$('#isEpolicyMali').val();
		if(isEpolicyMali=='1'){
		  	setEmailTemplate();
		}
	}
	//是否生成电子发票下载链接
	function invockLinkChange(flag1){
		var isEpolicyMali =$('#isEpolicyMali').val();
		if(isEpolicyMali=='1'){
		  	setEmailTemplate(flag1);
		}
	}
	function boxChange(){
		var isEpolicyMali =$('#isEpolicyMali').val();
		if(isEpolicyMali=='1'){
		  	setEmailTemplate();
		}
	}
//------------------------------------------配置代理信息结束-------------------------------------------
</script>
</head>
<body>
<c:if test="${not empty param.planCode }">
<input type="hidden" value="${param.planCode }" id="hidepno"/>
</c:if>

	      <div class="current" >
	           <table class="current_table_1">
	              <tbody>
		              <tr>
		                <td><img src="./images/current_1.jpg"></td>
		                  <td class="current_table_1_td"><img src="./images/current_1.png">&nbsp;您现在的位置：&nbsp;
			                  <span style=" color:#136bab; ">财险产品管理
			                  <span style="padding:0 5px; font-weight:bold; line-height:28px;">&gt;</span>方案配置
			                  <span style="padding:0 5px; font-weight:bold; line-height:28px;">&gt;</span>投保方案新增
			                  </span>
		                  </td>
		                  <td><img src="./images/current_3.jpg"></td>
		              </tr>
	           	  </tbody>
	           </table>
	      </div>
	      <div>
			<form id="inputForm" >
			<!-- <input id="agentType" type="hidden"> --><!--销售类型  -->
	        <table class="table_05">
	              <tbody>
		              <tr>
		                  <td colspan="4" style=" font-size:12px; font-weight:bold; text-align:left;color:#3876bf; line-height:17px; background-image:url(images/centent_1.jpg)">投保方案新增</td>
		              </tr>
		    		  <tr>
		                  <th width="10%">方案代码：</th>
		                  <td width="40%"><input name="planCode" id="planCode" type="text" readonly="readonly" style=" background-color: #ccc;" class="input_text"><span class="red">*</span>
		                  &nbsp;<span  style="${ptnEnv}">上线方案专用：<input type="checkbox" id='isProprod'/>&nbsp;<img src="/manager/images/caldef.jpg" title="此选项可保证测试环境与生产环境方案号一致及防止方案号冲突。仅供后续会升级正式环境的方案使用，不上线的方案不允许勾选！"></span>
		                  </td>
		                  <th width="10%">方案名称：</th>
		                  <td width="40%"><input id="planName" type="text" maxlength="100" class="input_text" ><span class="red">*</span></td>
		              </tr>
		              <tr>
		                  <th width="10%">产品代码：</th>
		                  <td width="40%">
		                  	<input name="prodCode" id="prodCode" type="text" readonly="readonly" style=" background-color: #ccc;" class="input_text"><span class="red">*</span>&nbsp;
		                  	<input type="button"  class="input_button_2" id="searchProdBtn" value="请选择" onClick="openProdDiv(1,this)"/>
		                  </td>
		                  <th width="10%">产品名称：</th>
		                  <td width="40%"><input name="prodName" id="prodName" type="text" readonly="readonly" style=" background-color: #ccc;" class="input_text"><span class="red">*</span></td>
		              </tr>
		              <tr>
		              	  <th>合作伙伴：</th>
		                  <td>
		                  	<input name="partnerCode" id="partnerCode" type="text" readonly="readonly" style=" background-color: #ccc;" class="input_text"><span class="red">*</span>&nbsp;
		                  	<input type="button"  class="input_button_2" id="searchPartnerBtn" value="请选择" onClick="openThisDiv(1,this)"/>
		                  </td>
		                  <th id="deptCode101">出单机构：</th>
		                  <td id="deptCode102">
		                  	<input id="deptCode"  type="text" readonly="readonly" style=" background-color: #ccc;" class="input_text"><span class="red" name="wxflag">*</span>&nbsp;
		                  	<input type="button"  class="input_button_2" id="searchDeptBtn" value="请选择" onClick="openDeptDiv(1,this)"/>
		                  </td>
		              </tr>
		              <tr>
		              	  <th>方案销售类型：</th>
		                  <td>
		                  		<select id="agentType" name="agentTypeSel" onchange="agentChange()" class="select_1 valid" style="visibility: visible;">
	 								<c:forEach var ="agentType" items="${agentTypes}">
		                  				<option value="${agentType.code}" title="${agentType.codeName}">${agentType.codeName}</option>
		                  			</c:forEach>
		                  		</select>
		                  </td>
		                  <th>跟单费用配置：</th>
		                  <td>
		                  	<select id="agentFeeConfig" name="agentFeeConfig" onchange="agentFeeConfigChange()" class="select_1 valid" style="visibility: visible;background-color: #ccc;"  disabled="disabled">
			                  	 <option value="" >请选择</option>
	                  			 <option value="1" >接口传入</option>
			                  	 <option value="2" >合作伙伴配置</option>
	                  		</select>
		                  </td>
	              </tr>
		              <tr  id="qudaoandlaiyuan01">
		                  <th>归属渠道：</th>
		                  <td>
		                  <select id=channelCodeQD class="select_1 valid" style="visibility: visible;">
		                  		<option value="">-----请选择-----</option>
		                  		<c:forEach var ="btcList" items="${btcList}">
		                  			<option value="${btcList.code}">${btcList.codeName}</option>
		                  		</c:forEach>
		                  </select><span class="red" name="wxflag">*</span></td>
		                  <th>渠道类型：</th>
		                  <td>
		                  <select id="channelType" class="select_1 valid" style="visibility: visible;">
		                  		<option value="">-----请选择-----</option>
		                  		<c:forEach var ="channelList" items="${channelList}">
		                  			<option value="${channelList.code}">${channelList.codeName}</option>
		                  		</c:forEach>
		                  </select><span class="red" name="wxflag">*</span></td>
		              </tr>
		              <tr  id="qudaoandlaiyuan02">
		                  <th>新业务来源：</th>
		                  <td>
		                  <select id="newBsnsType" class="select_1 valid" style="visibility: visible;">
		                  		<option value="">-----请选择-----</option>
		                  		<c:forEach var ="newBSList" items="${newBSList}">
		                  			<option value="${newBSList.code}">${newBSList.codeName}</option>
		                  		</c:forEach>
		                  </select><span class="red" name="wxflag">*</span></td>
		                  <th>旧业务来源：</th>
		                  <td>
		                  <select id="bsnsType" class="select_1 valid" style="visibility: visible;">
		                  		<option value="">-----请选择-----</option>
		                  		<c:forEach var ="oldBSList" items="${oldBSList}">
		                  			<option value="${oldBSList.code}">${oldBSList.codeName}</option>
		                  		</c:forEach>
		                  </select><span class="red" name="wxflag">*</span></td>
		              </tr>
		              <tr>
		                  <th id='cRate'>手续费比例：</th>
		                  <td>
		                  	<input name="commRate" id="commRate" type="text"  maxlength="10" class="input_text" onKeyUp="clearNoNum(event,this)" onBlur="checkNum(this)">
		                  	<span class="red">*</span>&nbsp;<span id="commRateSpan" class="blue"></span>
		                  </td>
		                   <th id='mRate'>市场维护费比例：</th>
		                  <td>
		                  	<input name="marketPreserveRate" id="marketPreserveRate" type="text"  maxlength="10" class="input_text" onKeyUp="clearNoNum(event,this)" onBlur="checkNum(this)">
		                  	<span class="red" style="margin-left: -5px">*</span>&nbsp;
		                  </td>	             
		                </tr>
		              <tr>
		                 <th id='bRate'>业务绩效比例：</th>
		                  <td>
		                    <input name="businessPerformanceRate" id="businessPerformanceRate" type="text"  maxlength="10" class="input_text" onKeyUp="clearNoNum(event,this)" onBlur="checkNum(this)">
		                  	<span class="red" style="margin-left: -5px">*</span>&nbsp;
		                  </td>
		                  <th>方案状态：</th>
		                  <td><select id="status" class="select_1 valid" style="visibility: visible;"><option value="0">无效</option><option value="1">有效</option></select></td>
		              </tr>
		              <!-- --------------------------根据产品销售方式的不同改变以下内容-------------------------------------- -->		              
		              <!--agentType1  合作伙伴代理   -->
		              <tr id="agentType101">
		                  <th>服务代码：</th>
		                  <td><input name="serviceCode" id="serviceCode" type="text" maxlength="20" class="input_text"><span class="red" name="wxflag">*</span></td>
		                  <th>业务员代码：</th>
		                  <td><input name="empNo" id="empNo" type="text"  maxlength="10" class="input_text"><span class="red" name="wxflag">*</span></td>
		              </tr>
		                <!--广东分公司个人销售业务信息 -->
		              <tr id="sale1" style="display:none">
		                  <th>跟单人员配置信息：</th>
		                  <td colspan="3"><input type="button" onclick="opensaleDiv()" value="广东销售信息配置"/></td>
		              </tr>
		              <tr id="sale2" style="display:none">
		                  <td colspan="4">
		                  	<div style="width:1100px; height:200px; overflow:scroll;">
			                  	<table id="agentType30Table"  style="width:99%;">
			                  		<thead>
										<tr style="background-color: C0C0C0;">
							                  <th style="border: #292421 solid 1px;width:100px;text-align: center;">序号</th>
							                  <th style="border: #292421 solid 1px;width:100px;text-align: center;">销售员类型<span style="margin-left: -5px" class="red">*</span></th>
							                  <th style="border: #292421 solid 1px;width:100px;text-align: center;">费用比例<span style="margin-left: -5px" class="red">*</span></th>
							                  <th style="border: #292421 solid 1px;width:100px;text-align: center;">执业证号</th>
							                  <th style="border: #292421 solid 1px;width:100px;text-align: center;">人员类别<span style="margin-left: -5px" class="red">*</span></th>
							                  <th style="border: #292421 solid 1px;width:100px;text-align: center;">业务员<span style="margin-left: -5px" class="red">*</span></th>
							                  <th style="border: #292421 solid 1px;width:100px;text-align: center;">销售员</th>
							                  <th style="border: #292421 solid 1px;width:100px;text-align: center;">代理人编号</th>
							              	</tr>
									</thead>
									<tbody id='saleShowDiv'>
						            </tbody>
			                  	</table>
		                  	</div>
		                  </td>
		              </tr>	
		              <!-- 广东分公司个人销售业务信息结束 -->
		              <tr id="agentType102">
		              	  <th>团队代码：</th>
		                  <td><input name="teamCode" id="teamCode" class="input_text" maxlength="11"></td>
		                  <th>团队名称：</th>
		                  <td><input name="teamName" id="teamName" class="input_text"></td>
		              </tr>
		              <tr id="agentType103">
		                  <th>代理人代码：</th>
		                  <td><input name="agentNo" id="agentNo" type="text"  maxlength="20" class="input_text"><span class="red">*</span></td>
		                  <th>代理人协议号：</th>
		                  <td><input name="protocolNo" id="protocolNo" type="text"  maxlength="13" class="input_text"><span class="red">*</span></td>
		              </tr>
		              <!--agentType3   个人代理   -->
		              <tr id="agentType301" style="display:none">
		              	  <th>个人销售业务信息:</th>
		                  <td colspan="3"><input type="button" disabled="disabled" onclick="openNocarAgentType3Div(1,this)" disabled="disabled" value="配置个人销售渠道信息"/></td>
		              </tr>
		              <c:if test="${not empty planCode}">
					  <tr id="agentType302" style="display:none">
		                  <td colspan="4">
		                  	<div style="width:1100px; height:auto; overflow:scroll;">
			                  	<table id="agentType3Table"  style="width:1400px;">
			                  		<thead>
										<tr style="background-color: C0C0C0;">
						                  <th style="border: #292421 solid 1px;width:100px;text-align: center;">用户名</th>
						                  <th style="border: #292421 solid 1px;width:100px;text-align: center;">姓名</th>
						                  <th style="border: #292421 solid 1px;width:100px;text-align: center;">出单机构</th>
						                  <th style="border: #292421 solid 1px;width:100px;text-align: center;">服务代码</th>
						                  <th style="border: #292421 solid 1px;width:100px;text-align: center;">业务员代码</th>
						                  <th style="border: #292421 solid 1px;width:100px;text-align: center;">单证领用人</th>
						                  <th style="border: #292421 solid 1px;width:100px;text-align: center;">团队代码</th>
						                  <th style="border: #292421 solid 1px;width:100px;text-align: center;">归属渠道</th>
						                  <th style="border: #292421 solid 1px;width:100px;text-align: center;">渠道类型</th>
						                  <th style="border: #292421 solid 1px;width:100px;text-align: center;">新业务来源</th>
						                  <th style="border: #292421 solid 1px;width:100px;text-align: center;">原业务来源</th>
						                  <th style="border: #292421 solid 1px;width:100px;text-align: center;">代理人编码</th>
						                  <th style="border: #292421 solid 1px;width:100px;text-align: center;">代理协议号</th>
						                  <th style="border: #292421 solid 1px;width:100px;text-align: center;">手续费比例</th>
						              	  <th style="border: #292421 solid 1px;width:130px;text-align: center;">市场维护费比例</th>
						              	  <th style="border: #292421 solid 1px;width:100px;text-align: center;">业务绩效比例</th>
						              	</tr>
									</thead>
									<tfoot>
										<tr>
						                  <td colspan="14">
						                  	<div id="agentType3TablePageDIV" class="page"></div>
						                  </td>
						              	</tr>
									</tfoot>
									<tbody>
						            </tbody>
			                  	</table>
		                  	</div>
		                  </td>
		              </tr>	
					  </c:if>
		              <!--agentType4   总对总代理   -->
		              <tr id="agentType401" style="display:none">
		              	  <th>总对总销售业务信息:</th>
		                  <td colspan="3"><input type="button" disabled="disabled" onclick="openNocarAgentType4Div(1,this)" disabled="disabled" value="配置总对总销售渠道信息"/></td>
		              </tr>
		              <c:if test="${not empty planCode}">
					  <tr id="agentType402" style="display:none">
		                  <td colspan="4">
		                  	<div style="width:1100px; height:auto; overflow:scroll;">
			                  	<table id="agentType4Table"  style="width:2000px;">
			                  		<thead>
										<tr style="background-color: C0C0C0;">
						                  <th style="border: #292421 solid 1px;width:100px;text-align: center;">网点代码</th>
						                  <th style="border: #292421 solid 1px;width:100px;text-align: center;">网点名称</th>
						      			  <th style="border: #292421 solid 1px;width:100px;text-align: center;">用户名</th>
						                  <th style="border: #292421 solid 1px;width:100px;text-align: center;">姓名</th>          
						                  <th style="border: #292421 solid 1px;width:100px;text-align: center;">区域代码</th>
						                  <th style="border: #292421 solid 1px;width:100px;text-align: center;">出单机构</th>
						                  <th style="border: #292421 solid 1px;width:100px;text-align: center;">服务代码</th>
						                  <th style="border: #292421 solid 1px;width:100px;text-align: center;">业务员代码</th>
						                  <th style="border: #292421 solid 1px;width:100px;text-align: center;">单证领用人</th>
						                  <th style="border: #292421 solid 1px;width:100px;text-align: center;">团队代码</th>
						                  <th style="border: #292421 solid 1px;width:100px;text-align: center;">归属渠道</th>
						                  <th style="border: #292421 solid 1px;width:100px;text-align: center;">渠道类型</th>
						                  <th style="border: #292421 solid 1px;width:100px;text-align: center;">新业务来源</th>
						                  <th style="border: #292421 solid 1px;width:100px;text-align: center;">原业务来源</th>
						                  <th style="border: #292421 solid 1px;width:100px;text-align: center;">代理人编码</th>
						                  <th style="border: #292421 solid 1px;width:100px;text-align: center;">代理协议号</th>
						                  <th style="border: #292421 solid 1px;width:100px;text-align: center;">手续费比例</th>
						              	  <th style="border: #292421 solid 1px;width:100px;text-align: center;">市场维护费比例</th>
						              	  <th style="border: #292421 solid 1px;width:100px;text-align: center;">业务绩效比例</th>
						              	</tr>
									</thead>
									<tfoot>
										<tr>
						                  <td colspan="15">
						                  	<div id="agentType4TablePageDIV" class="page"></div>
						                  </td>
						              	</tr>
									</tfoot>
									<tbody>
						            </tbody>
			                  	</table>
		                  	</div>
		                  </td>
		              </tr>	
					  </c:if>
				<!--agentType6  销售类型6 跟单费用配置接口传入  -->
	              <tr id="agentType601" style="display:none">
	                  <th>第三方传入方案跟单费用配置：</th>
	                  <td colspan="3"><input type="button" disabled="disabled" onclick="openAgentInfo6Div()" value="跟单费用配置选择"/></td>
	              </tr>
					<!-- 方案接口传入结束 -->	
<!-- --------------------------根据产品销售方式的不同改变以上内容-------------------------------------- -->		              
		              <tr>
		                  <th>是否见费出单：</th>
		                  <td><select id="isSeeMoney" onchange="SeeMoneyChange()" class="select_1 valid" style="visibility: visible;"><option value="N">否</option><option value="Y">是</option></select></td>
		                  <th>是否电子保单：</th>
		                  <td>
			                  	<div id="Download_left" style="float: left; width: 15%"><select id="isEpolicy" class="select_1 valid" onchange="IsEpolicyChange()" style="visibility: visible; width: 60px"><option value="N">否</option><option value="Y">是</option></select></div>
		                  		<div id="Download_right" style="float: left;display: none;">
									下载方式：<select id="DownloadWay" class="select_1 valid" style="visibility: visible;width: 100px" onchange='downloadWayChange()'><option value="0">实时电子保单</option><option value="1">影像系统获取</option></select>		                  		
		                  			<span style="display: none;" id='fileTypeSpan'>文件方式：
			                  			<select id="fileType" class="select_1 valid" style="visibility: visible;width: 80px;" onchange="fileTypeChange()">
			                  				<c:forEach var ="fileType" items="${fileTypes}">
				                  				<option value="${fileType.code}">${fileType.codeName}</option>
				                  			</c:forEach>
			                  			</select>
		                  			</span>		                  		
		                  		</div>	
		                  </td>
		              </tr>
		              <tr>
		                  <th>是否打印单证：</th>
		                  <td>
		                  	<select id="isPrintCard" onchange="checkPrintCard()" class="select_1" style="visibility: visible;">
		                  		<option value="">----请选择----</option>
		                  		<option value="Y">是</option>
		                  		<option value="N">否</option>
		                  	</select><span class="red">*</span>
		                  </td>
		                  <th>单证类型：</th>
		                  <td>
		                  	<div style="float: left;">
		                  		<input id="cardType" type="text" readonly="true" style=" background-color: #ccc;" class="input_text"><span class="red">*</span>
		                  	</div>
		                  	<div id="cardApplicant_div" style="float: left;">
		                  		单证领用人：<input id="cardApplicant" type="text" readonly="true" style=" background-color: #ccc; width:100px" class="input_text"><span class="red">*</span>
		                  	</div>
		                  </td>
		              </tr>
		              <tr>
					  		<th>是否发送电子发票：</th>
					  		<td><select onchange="epolicyInvoiceChange()" id="isEpolicyInvoice" class="select_1 valid" style="visibility: visible;" onchange="invockLinkChange()"><option value="2">否</option><option value="1">是</option></select>
					  		&nbsp;<span class='CinvockLink' style="display: none">电子发票下载链接&nbsp;</span><select id="invockLink" class="select_1 valid CinvockLink" style="visibility: visible;width: 70px;display: none"><option value="N">不生成</option><option value="Y">生成</option></select>
					    	<img class='CinvockLink'  style="display: none" src="/manager/images/caldef.jpg" title="如果需要接口、邮件、或短信内容包括电子发票下载链接，则需选择“生成”选项">
					  		</td>	
					  		<th>是否开通支付平台：</th>
					  		<td><select id="isDredgePay" class="select_1 valid" disabled="disabled" style="visibility: visible; background-color: #ccc"><option value="1">是</option><option value="2">否</option></select></td>			
					  </tr>
					  <tr id="einvoiceInfo" style="display: none">
						<th>发票购方：</th>
				  		<td>
							<select id="payEinvoice" class="select_1 valid" style="visibility: visible;width: 100px;">
                  				<c:forEach var ="payEinvoice" items="${payEinvoices}">
	                  				<option value="${payEinvoice.code}">${payEinvoice.codeName}</option>
	                  			</c:forEach>
		                  	</select>
			  			</td>	
				  		<th >承保时支持开票：</th>
				  		<td >
				  			<select id="isInsuranceEinvoice" class="select_1 valid" style="visibility: visible;" onchange="isInsurEinvoiceChange()"><option value="Y">是</option><option value="N">否</option></select>
				  		</td>						  		
			  		</tr>
					  <tr>
		              	 <th>是否发送承保短信：</th>
		                  <td>
		                  	<div style="float: left;width:18%;">
		                  		<select name="is_message" onchange="checkIsMessage()" id="is_message" class="select_1 valid" style="visibility: visible;width:95%;"><option value="N">否</option><option value="Y">是</option></select>
		                  	</div>
		                  	<div id="messageReceiverDiv"  style="float: left;display:none;width:35%;">
		                  		接收人：<select name="messageReceiver"    id="messageReceiver" class="select_1 valid" style="visibility: visible;width:65%;"><option value="">请选择</option><option value="0">投保人</option><option value="1">被保人</option></select>
		                  	</div>
		                  	<div id="smsTemplateDiv"  style="float: left;display:none;width:47%;">
		                  		短信模板：
		                  		<select name="smsTemplate" id="smsTemplate" onchange="changeIsMessageTemplate()"  class="select_1 valid" style="visibility: visible;width:60%;">
		                  			<option value="">----请选择----</option>
		                  			<c:forEach var ="messageList" items="${messageList}">
		                  				<option value="${messageList.smsTemplateCode}">${messageList.smsTemplateName}</option>
		                  			</c:forEach>
		                  		</select>
		                  	</div>
		                  </td>
		                   <th>是否发送注销短信：</th>
		                  <td>
		                 	  <div style="float: left;width:18%;">
		                  		<select name="isCancelMessage" id="isCancelMessage" onchange="changeIsCancelMessage()" class="select_1 valid" style="visibility: visible;width:95%;">
			                  		<option value="N">否</option>
			                  		<option value="Y">是</option>
		                  		</select>
		                  	  </div>
		                  	  <div id="cancelReceiverDiv"  style="float: left;display:none;width:35%;">
		                  		接收人:<select name="cancelReceiver"  id="cancelReceiver" class="select_1 valid" style="visibility: visible;width: 65%;"><option value="">----请选择---</option><option value="0">投保人</option><option value="1">被保人</option></select>
		                  	  </div>
		                  	  <div id="cancelTemplateDiv"  style="float: left;display:none;width:47%;">
		                  		短信模板：
		                  		<select name="isCancelTemplate"  id="isCancelTemplate" onchange="changeIsCacelTemplate()" class="select_1 valid" style="visibility: visible;width:60%;">
		                  			<option value="">----请选择----</option>
		                  			<c:forEach var ="cacelList" items="${cacelList}">
		                  				<option value="${cacelList.smsTemplateCode}">${cacelList.smsTemplateName}</option>
		                  			</c:forEach>
		                  		</select>
			                  </div>
		                  </td>
		              </tr>
					  <tr>
					  		<th>是否发送电子邮件：</th>
					  		<td><select id="isEpolicyMali" onchange="CheckedSendMail()" class="select_1 valid" style="visibility: visible;"><option value="2">否</option><option value="1">是</option></select>
					  		  <span id="sendAccessory" style="display: none">
			                		  附件发送：
			                  </span>
					  		<span id="sendAccessoryTd" style="display: none">
						  		<c:if test="${not empty Accessorylist}">
						  				<c:forEach items="${Accessorylist}" var="acc">
						  					<c:if test="${acc.code =='01'}">
						  					<input type="checkbox" name="SendAccessoryBox" id="SendAccessoryBox"  value="${acc.code}" onchange="boxChange()"> <span style="margin-left: 5px">${acc.codeName}</span>
						  					</c:if>
						  				</c:forEach>
						  			</c:if>
						  			<c:if test="${not empty AccessoryEditlist}">
						  				<c:forEach items="${AccessoryEditlist}" var="acc">
						  					<c:if test="${acc.code =='01'}">
						  					<input type="checkbox" name="SendAccessoryBox" id="SendAccessoryBox"  value="${acc.code}" onchange="boxChange()"> <span style="margin-left: 5px">${acc.codeName}</span>
						  				</c:if>
						  				</c:forEach>
						  			</c:if>
					  		</span>
					  		</td>	
					  		<th >特别约定配置方式：</th>
					  		<td>
					  			<select id="specialConfigType" onchange="specialConfigTypeChange()" class="select_1 valid" style="visibility: visible;">
					  		      <option value="2">合作伙伴配置</option>
					  		      <option value="1">接口传入</option>
					  		    </select>
					  		</td>	
					  </tr>
					  	<tr>
							<th>分公司纳税人识别号：</th>
						  	<td><input id="dentification" class="input_text"/></td>	
						   <th>是否支持回执：</th>
						   <td>
		                  <div style="float:left;">
		                  		<select name="isReceipt" id="isReceipt" onchange="chooseReceiptType()" class="select_1 valid" style="visibility: visible;"><option value="N">否</option><option value="Y">是</option></select>
		                  </div>
		                  <div id="isOrNotDisplayReceiptTypeDiv"  style="float:left;display:none;">
			              	回执类型：<select id = "receiptType" class="select_1 valid" style="visibility: visible;vertical-align: middle; width: 110px;">
			                    <c:forEach var ="receiptTypeLsCode" items="${receiptTypeLs}">
				                	<option value="${receiptTypeLsCode.code}">${receiptTypeLsCode.codeName}</option>
				                </c:forEach>
			                  </select>
			              </div>
		                  </td>
				  		</tr>
				  		<tr>
						 <th>是否电子批单：</th>
		                 <td>
		                  <div style="float:left;">
		                  		<select name="isedrno " id="isedrno" onchange="chooseIsedrno()" class="select_1 valid" style="visibility: visible;"><option value="N">否</option><option value="Y">是</option></select>
		                  </div>
		                  <div id="isOrNotDisplayEdrnoTypeDiv"  style="float:left;display:none;">
			              	电子批单类型：<select id = "edrnoType " class="select_1 valid" style="visibility: visible;vertical-align: middle; width: 110px;">
			                    <c:forEach var ="receiptTypeLsCode" items="${edrnoTypes}">
				                	<option value="${receiptTypeLsCode.code}">${receiptTypeLsCode.codeName}</option>
				                </c:forEach>
			                  </select>
			              </div>
			              <th>是否电子保函：</th>
		                 <td>
		                  <div style="float:left;">
		                  		<select name="isEConfirm" id="isEConfirm"  class="select_1 valid" style="visibility: visible;" onchange="IsEconfirmChange()"><option value="N">否</option><option value="Y">是</option></select>
		                  </div>
		                  </td>
		                  </td>
				  		</tr>
					    <tr>
						    <th width="10%">是否已推送销售信息:  </th>
						    <td  class="input_text" >
							    <div style="float: left;width: 190px;">
								    <select id="isPushedSalesInfo" class="select_1 " style="background-color: #ccc; "disabled="disabled">
									    <option value="N">否</option>
									    <option value="Y">是</option>
								    </select>
							    </div>
						    </td>
					   </tr>
		               <tr id="MailTemplateTr" style="display: none;">
	              	  		<th>邮件模板配置：</th>
	              	  		<td colspan="3"><textarea name="MailTemplate" id="MailTemplate" rows="5" cols="" class="textarea_1" style="resize:none"></textarea><span class="red">*</span> </td>
	              	  </tr>
		              <tr id="messageTemplateTr" style="display:none">
		                  <th >承保短信模板配置：</th>
		                  <td colspan="3"><textarea name="messageTemplate" id="messageTemplate" cols="" rows="5" class="textarea_1" style="resize:none;">【燕赵保险】尊敬的客户您好，您已成功投保我司xxx险种，保单号为xxxxx。保险期间20150412--20150413。保单详细信息查询网站：http://query.cic.cn，报案电话95585。</textarea><span class="red">*</span></td>
	              	  </tr>
	              	   <tr id="cancelTemplateTr" style="display:none">
	                 		 <th>注销短信模板配置：</th>
	                  		<td colspan="3"><textarea name="cancelTemplate" id="cancelTemplate" rows="5" class="textarea_1" style="resize:none;"></textarea><span class="red">*</span></td>
	              		</tr>
		              <tr>
		                  <th>特别约定：</th>
		                  <td colspan="3"><textarea name="specialArran" id="specialArran" cols="" rows="5" class="textarea_1" style="resize:none;"></textarea></td>
	              	  </tr>
	           	  </tbody>
	         </table> 
	         <div align="center">
	             <input class="input_button_1" name="" id="sbtn" type="button" onclick="checkAndExcute()" value="保存">&nbsp;&nbsp;
		         <input class="input_button_1" name="" type="button" value="返回" onclick="goBack()">
	         </div>
	         </form>
	      </div>    

	
				<!--   	产品 DIV 默认隐藏-->
  		  		<div id="prodDiv"  style="display:none;width:80%;">
			<input type="hidden" id="row_num" name="row_num" value="0"/>
				<div class="table_title_div">
					<table class="table_title" style='width:100%;height: 20px;'>
						<tr>
						<td width="10%"></td>
						<td width="80%" id="interfaceName"></td>
						<td width="10%" align="right"><img src="./images/closedown.gif" alt="关闭"  onclick="closeCurrentDIV('prodDiv')"/></td>
						</tr>
					</table>
				</div>
	
			<!-- 修改id 名 -->
			<table class="table_02" id="addtempletTable" align="center" >
				<tbody>
				<tr>
				<td>
					<table class="search_table">
					<tr height="30px" >
							<td style="border:0px;text-align: right;">交易系统产品代码：</td>
							<td style="border:0px;text-align: left;">
								<input name="txt3"  id="prodcode"  type="text" class="input_text" value="" style="width:120px;">
							</td>
							<td style="border:0px;text-align: right;">
								交易系统产品描述：
							</td>
							<td style="border:0px;text-align: left;"><input name="txt3" id="proddesc"  type="text" class="input_text" value="" style="width:120px;"></td>
					</tr>
					<tr height="30px" >
							<td style="border:0px;text-align: right;">定义起期：</td>
							<td style="border:0px;text-align: left;">
								<input id="startDate" onkeydown="false" onclick="showCalendar('startDate','y-mm-dd');$('.calendars').css('z-index',20000);" class="input_time" type="text" style="width:120px;"/>
							</td>
							<td style="border:0px;text-align: right;">
							定义止期：
							</td>
							<td style="border:0px;text-align: left;">
								 <input id="endDate" onkeydown="false" onclick="showCalendar('endDate','y-mm-dd');$('.calendars').css('z-index',20000);" class="input_time" type="text" style="width:120px;"/>
								 &nbsp;&nbsp;&nbsp;&nbsp;
								<input type="button"  class="input_button_1" id="searchBtn" value="查询" onClick="queryTradProdInst(1)"/>
							</td>
					</tr>
				</table>
				</td></tr>
					<tr>
						<td>
							<!-- 修改数据table名 -->
							<table id="productTable"  class="content_table_1">
								<thead>
									<tr class="f1">
					                  <th style="width:5%">选择</th>
					                  <th style="width:45%">交易系统产品代码</th>
					                  <th style="width:50%">交易系统产品描述</th>
					              	</tr>
								</thead>
								<!-- 修改tobody 默认为空 -->
								<tbody>
								</tbody>
							</table>
							<!-- 修改分页编码id 名  默认为空-->
							<div id="productPageDIV" class="page">
							</div>
						</td>
					</tr>
				</tbody>
			</table>
			<div align="center" >
			 <input class="input_button_3" name="" type="button" onclick="chooseProd()" value="确定">&nbsp;&nbsp;
	         <input class="input_button_3" name="" type="button" onclick="closeCurrentDIV('prodDiv')" value="取消">
			</div>
	   </div>
	
	
	<!--   	选择 合作伙伴 div-->
  		<div id="tradPartnerDiv" style="display:none;width:80%;">
  		<input type="hidden" id="row_num" name="row_num" value="0"/>
			<div class="table_title_div">
					<table class="table_title" style='width:100%;height: 20px;'>
						<tr>
						<td width="10%"></td>
						<td width="80%" id="interfaceName"></td>
						<td width="10%" align="right"><img src="./images/closedown.gif" alt="关闭"  onclick="closeCurrentDIV('tradPartnerDiv')"/></td>
						</tr>
					</table>
			</div>
		<table class="table_02" id="table" style="height:180px;" align="center">
			<tr>
				<td>
					<table class="search_table">
						<tr height="30px">
							<td colspan="3" style="text-align:center">
							 合作伙伴代码：<input name="txt3"  id="channelCode"  type="text" class="input_text" value="" >&nbsp;&nbsp;
							 合作伙伴名称：<input name="txt3" id="channelName"  type="text" class="input_text" value="">&nbsp;&nbsp;
								       <input type="button"  class="input_button_1" id="searchBtn" value="查询" onClick="queryTradPartners(1)"/>
							</td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td>
					<table id="TradPartnerTable"  class="content_table_1">
						<thead>
							<tr class="f1">
			                  <th style="width:5%">选择</th>
			                  <th style="width:10%">合作伙伴代码</th>
			                  <th style="width:20%">合作伙伴名称</th>
			              	</tr>
						</thead>
						<tbody>
						</tbody>
					</table>
					<div id="TradPartnerPageDIV"  class="page"></div>
				</td>
			</tr>
		</table>
		<div align="center" >
		  <input type="button" id="saveRoleBtn" value="确定" onclick="choosePartner()" class="input_button_3"/>&nbsp;&nbsp;&nbsp;
		  <input type="button" value="取消" onclick="closeCurrentDIV('tradPartnerDiv')" class="input_button_3"/>
		</div>
	</div>	
	
	
	
		<!--   	机构 DIV 默认隐藏-->
	<div id="deptDiv" style="display:none;width:80%;">
  		<input type="hidden" id="row_num" name="row_num" value="0"/>
			<div class="table_title_div">
					<table class="table_title" style='width:100%;height: 20px;'>
						<tr>
						<td width="10%"></td>
						<td width="80%" id="interfaceName"></td>
						<td width="10%" align="right"><img src="./images/closedown.gif" alt="关闭"  onclick="closeCurrentDIV('deptDiv')"/></td>
						</tr>
					</table>
			</div>
		<table class="table_02" id="table" style="height:180px;" align="center">
			<tr>
				<td>
					<table class="search_table">
						<tr height="30px">
							<td colspan="3" style="text-align:center">
							 出单机构代码：<input name="txt3"  id="deptcode"  type="text" class="input_text" value="" >&nbsp;&nbsp;
							 出单机构名称：<input name="txt3" id="deptcnname"  type="text" class="input_text" value="">
								       <input type="button"  class="input_button_1" id="searchBtn" value="查询" onClick="queryCoreDept(1)"/>
							</td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td>
					<table id="deptTable"  class="content_table_1">
						<thead>
							<tr class="f1">
			                  <th style="width:5%">选择</th>
			                  <th style="width:45%">出单机构代码</th>
			                  <th style="width:50%">出单机构名称</th>
			              	</tr>
						</thead>
						<tbody>
						</tbody>
					</table>
					<div id="deptPageDIV"  class="page"></div>
				</td>
			</tr>
		</table>
		<div align="center" >
		  <input type="button" id="saveRoleBtn" value="确定" onclick="chooseDept()" class="input_button_3"/>&nbsp;&nbsp;&nbsp;
		  <input type="button" value="取消" onclick="closeCurrentDIV('deptDiv')" class="input_button_3"/>
		</div>
	</div>	
	<!--配置个人代理信息 div-->
  	<div id="agentTypeDiv3" style="display:none;width:100%;">
		<div class="table_title_div">
			<table class="table_title" style='width:100%;height: 20px;'>
				<tr>
				<td width="10%"></td>
				<td width="80%" id="interfaceName"></td>
				<td width="10%" align="right"><img src="./images/closedown.gif" alt="关闭"  onclick="closeNocarAgentTypeDiv('agentTypeDiv3')"/></td>
				</tr>
			</table>
		</div>
		<table class="table_02" id="table" style="height:240px;" align="center">
			<tr>
				<td>
					<table class="search_table">
						<tr height="30px">
							<td colspan="10" style="text-align:center">
							<!-- 表单号不为空即编辑时显示配置状态 -->
							<c:if test="${not empty planCode}">
								配置状态：<select id="confStatus"><option value="ALL">全部</option><option value="YES">已配置</option><option value="NO">未配置</option></select>&nbsp;&nbsp;
							</c:if>
							<c:if test="${empty planCode}">
								<input id="confStatus" type="hidden"  value="ALL">
							</c:if> 
							 代理人姓名：<input id="agentName" type="text" class="input_text" value="">&nbsp;&nbsp;
							 代理人编码：<input id="agentNo" type="text" class="input_text" value="">&nbsp;&nbsp;
								<input type="button"  class="input_button_1" id="searchBtn" value="查询" onClick="queryNocarConfProxyInfo3(1)"/>
							</td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td>
					<table id="agentTypeDiv3Table"  class="content_table_1">
						<thead>
							<tr class="f1">
			                  <th style="width:5%">选择</th>
			                  <th style="width:10%">代理个人</th>
			                  <th style="width:10%">出单机构</th>
			                  <th style="width:10%">代理人编码 </th>
			                  <th style="width:10%">代理协议号</th>
			                  <th style="width:10%">服务代码</th>
			                  <th style="width:10%">业务员代码</th>
			                  <th style="width:10%">单证领用人</th>
			                  <th style="width:10%">团队代码 </th>
			                  <th style="width:10%">手续费比例 </th>
			              	</tr>
						</thead>
						<tbody>
						</tbody>
					</table>
					<div id="agentTypeDiv3Page"  class="page"></div>
				</td>
			</tr>
		</table>
		<div align="center" >
		  <input type="button" id="saveRoleBtn" value="保存" onclick="chooseNocarAgentType3()" class="input_button_3"/>&nbsp;&nbsp;&nbsp;
		  <input type="button" value="取消" onclick="closeNocarAgentTypeDiv('agentTypeDiv3')" class="input_button_3"/>
		</div>
	</div>
	
	<!--配置总对总代理信息 div-->
  	<div id="agentTypeDiv4" style="display:none;width:100%;">
		<div class="table_title_div">
			<table class="table_title" style='width:100%;height: 20px;'>
				<tr>
				<td width="10%"></td>
				<td width="80%" id="interfaceName"></td>
				<td width="10%" align="right"><img src="./images/closedown.gif" alt="关闭"  onclick="closeNocarAgentTypeDiv('agentTypeDiv4')"/></td>
				</tr>
			</table>
		</div>
		<table class="table_02" id="table" style="height:240px;" align="center">
			<tr>
				<td>
					<table class="search_table">
						<tr height="30px">
							<td colspan="10" style="text-align:center">
							<!-- 表单号不为空即编辑时显示配置状态 -->
							<c:if test="${not empty planCode}">
								配置状态：<select id="confStatus4"><option value="ALL">全部</option><option value="YES">已配置</option><option value="NO">未配置</option></select>&nbsp;&nbsp;
							</c:if>
							<c:if test="${empty planCode}">
								<input id="confStatus4" type="hidden"  value="ALL">
							</c:if> 
							 合作伙伴子机构：<input id="subChannelName" type="text" class="input_text" value="">&nbsp;&nbsp;
							 合作伙伴子机构代码：<input id="subChannelCode" type="text" class="input_text" value="">&nbsp;&nbsp;
								<input type="button"  class="input_button_1" id="searchBtn" value="查询" onClick="queryNocarConfProxyInfo4(1)"/>
							</td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td>
					<table id="agentTypeDiv4Table"  class="content_table_1">
						<thead>
							<tr class="f1">
			                  <th style="width:5%">选择</th>
			                  <th style="width:10%">合作伙伴子机构</th>
			                  <th style="width:10%">区域代码</th>
			                  <th style="width:10%">出单机构 </th>
			                  <th style="width:10%">代理人编码</th>
			                  <th style="width:10%">代理协议号</th>
			                  <th style="width:10%">服务代码</th>
			                  <th style="width:10%">业务员代码</th>
			                  <th style="width:10%">单证领用人 </th>
			                  <th style="width:10%">团队代码 </th>
			                  <th style="width:10%">手续费比例 </th>
			              	</tr>
						</thead>
						<tbody>
						</tbody>
					</table>
					<div id="agentTypeDiv4Page"  class="page"></div>
				</td>
			</tr>
		</table>
		<div align="center" >
		  <input type="button" id="saveRoleBtn" value="保存" onclick="chooseNocarAgentType4()" class="input_button_3"/>&nbsp;&nbsp;&nbsp;
		  <input type="button" value="取消" onclick="closeNocarAgentTypeDiv('agentTypeDiv4')" class="input_button_3"/>
		</div>
	</div>
		<!--广东分公司配置销售人员信息div-->
  	<div id="sale_div" style="display:none;width:1000px; height:450px;">
		<div class="table_title_div" style="width: 990px">
			<table class="table_title" style='width:990px;height: 20px;'>
				<tr>
				<td width="120px"></td>
				<td width="1460px" id="interfaceName"></td>
				<td width="60px" align="right"><img src="./images/closedown.gif" alt="关闭"  onclick="closeNocarAgentTypeDiv('sale_div')"/></td>
				</tr>
			</table>
		</div>
		<table class="table_02" id="table" style="width:990px;" align="center">
			<tr>
				<td>
					<table id="sale3"  class="content_table_1">
						<thead>
							<tr class="f1">
			               	  <th style="width:90px">序号</th>
			                  <th style="width:110px">销售员类型<span style="margin-left: -5px" class="red">*</span></th>
			                  <th style="width:90px">费用比例<span style="margin-left: -5px" class="red">*</span></th>
			                  <th style="width:90px">执业证号</th>
			                  <th style="width:90px">人员类别<span style="margin-left: -5px" class="red">*</span></th>
			                  <th style="width:90px">销售员</th>
			                  <th style="width:90px">业务员<span style="margin-left: -5px" class="red">*</span></th>
			                  <th style="width:90px">代理人编号</th>
			              	</tr>
						</thead>
						<tbody id='salecontent'>
						</tbody>
					</table>
				</td>
			</tr>
		</table>
		<div align="center" >
		  <input type="button" id="saveSaleBtn" value="保存" onclick="saveSale()" class="input_button_3"/>&nbsp;&nbsp;&nbsp;
		  <input type="button" value="取消" onclick="closeNocarAgentTypeDiv('sale_div')" class="input_button_3"/>
		</div>
	</div>
	<!-- 接口传入方案 -->
	<input type="hidden" id='isThirdPlan'>
</body>
</html>